我想连接到aspnetdb,但它显示错误"Login failed for user“这是web配置中的连接字符串:
<add name="UserProfiles" connectionString="Data Source=KIA;Initial Catalog=aspnetdb;Integrated Security=True;"
providerName="System.Data.SqlClient" />这是我的代码:
SqlConnection connection = new SqlConnection();
SqlCommand ComNewCheckSum = new SqlCommand();
connection.ConnectionString = ConfigurationManager.ConnectionStrings["UserProfiles"].ConnectionString;
connection.Open();
ComNewCheckSum.Connection = connection;
ComNewCheckSum.CommandText = String.Format("select UserID from aspnet_Users where UserName = {0}", _UserName);
return Convert.ToInt32(ComNewCheckSum.ExecuteScalar());我如何通过错误传递?谢谢
发布于 2010-10-20 23:28:34
在您的连接字符串中,您使用了“集成的Security=True",这意味着您正在尝试使用您的Windows凭据连接到此数据库,这似乎不适合访问此数据库。
尝试使用您知道可以访问此数据库的用户和密码,并更新您的连接字符串,使其使用该信息-示例:
<add name="UserProfiles" connectionString="Data Source=KIA;Initial Catalog=aspnetdb;User ID=someuser;Password=somepassword;"
providerName="System.Data.SqlClient" />https://stackoverflow.com/questions/3966446
复制相似问题