首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何直接连接aspnetdb数据库

如何直接连接aspnetdb数据库
EN

Stack Overflow用户
提问于 2010-10-19 16:21:37
回答 1查看 1.1K关注 0票数 1

我想连接到aspnetdb,但它显示错误"Login failed for user“这是web配置中的连接字符串:

代码语言:javascript
复制
<add name="UserProfiles" connectionString="Data Source=KIA;Initial Catalog=aspnetdb;Integrated Security=True;"
   providerName="System.Data.SqlClient" />

这是我的代码:

代码语言:javascript
复制
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());

我如何通过错误传递?谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-10-20 23:28:34

在您的连接字符串中,您使用了“集成的Security=True",这意味着您正在尝试使用您的Windows凭据连接到此数据库,这似乎不适合访问此数据库。

尝试使用您知道可以访问此数据库的用户和密码,并更新您的连接字符串,使其使用该信息-示例:

代码语言:javascript
复制
<add name="UserProfiles" connectionString="Data Source=KIA;Initial Catalog=aspnetdb;User ID=someuser;Password=somepassword;"
   providerName="System.Data.SqlClient" />
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3966446

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档