当我从Visual 2010启动应用程序时,会显示以下错误:
值不能为空。\r\n参数名称:用户名
在此方法的参数发送方中,我可以在Global.asax.cs中看到此错误:
void Application_Error(object sender, EventArgs e)
{
}问题是我没有在任何地方使用用户名和我的web.config
<configuration>
<connectionStrings>
<add name="MYSQL"
connectionString="Driver={MySQL ODBC 5.2w Driver};Server=server_name;Database=database_name;uid=my_user_id;pwd=my_pwd"
providerName="System.Data.Odbc"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
</configuration>欢迎任何帮助。
编辑:
更多信息:
我能看到的是:
sender.base.Profile.base.base.Session = '((System.Web.HttpApplication)(sender)).Session' threw an exception of type 'System.Web.HttpException' 和
sender.Profile.base.LastActivityDate = '((System.Web.Profile.ProfileBase)(((ASP.global_asax)(sender)).Profile)).LastActivityDate' threw an exception of type 'System.ArgumentNullException' 和
sender.Profile.base.LastActivityDate.base = {"Value cannot be null.\r\nParameter name: username"}编辑
这段代码没有任何问题,我也可以执行查询。
void Application_Start(object sender, EventArgs e)
{
string ConnStr = System.Configuration.ConfigurationManager.ConnectionStrings["MYSQL"].ConnectionString;
OdbcConnection con = new OdbcConnection(ConnStr);
con.Open();
con.Close();
}发布于 2012-12-12 08:25:22
由于某些原因,此错误仅在我从Visual运行应用程序时发生,而不是在IIS中部署应用程序时发生。
谢谢你的帮助!
发布于 2012-11-30 10:30:41
连接字符串格式错误。
可能应该是:
Driver={MySQL ODBC 5.2w Driver};Server=server_name;Database=database_name;User=my_user_id;Password=my_pwdUser代替了uid,Password代替了pwd。
有关不同的选项,请参见connectionstrings.com。
https://stackoverflow.com/questions/13643275
复制相似问题