【发布时间】:2013-01-29 01:59:05
【问题描述】:
我遇到的问题是从 ASP.NET 应用程序连接到我的 sql server (2005) 上的帐户。
我尝试使用默认的 sa 登录名,并且我已经创建的用户也将 sql management studio 的设置设置为混合属性,我在 webconfig 中也有字符串连接,但也不起作用。
c#代码
//string conStr = ConfigurationManager.ConnectionStrings["SQLConnectionString"].ConnectionString;
string conStr = @"server=JAMES-PC\SQLEXPRESS; database=projectDB; uid=james; password=password;";
string query = "SELECT [TaskID], [Task], [Start Date] AS Start_Date, [End Date] AS End_Date, [Priority], [Time Allowance] AS Time_Allowance, [Details], [Catagory] FROM [schedulerData0]";
SqlDataAdapter dataAdapt = new SqlDataAdapter(query, conStr);
DataTable table = new DataTable();
dataAdapt.Fill(table);
GridView1.DataSource = table;
GridView1.DataBind();
我收到的错误信息是:
用户“james”登录失败。该用户未与受信任的 SQL Server 连接关联。
任何帮助表示赞赏 詹姆斯
【问题讨论】:
-
也许您需要 IntegratedSecurity=SSPI ?
-
使用sql账户时设置IntegratedSecurity=false
-
这段代码在 webconfig 中的什么位置?或管理工作室中的某个地方
-
好的,谢谢您的回复
标签: c# asp.net sql-server dataadapter