[英]Why won't my c# connection string to a SQL server work with Windows authentication?
Why won't my connection string to SQL server work with Windows authentication? 为什么我与SQL Server的连接字符串不能与Windows身份验证一起使用? A sql user works fine, acme\\administrator or administrator@acme.com won't work.
sql用户工作正常,acme \\ administrator或administrator@acme.com无法正常工作。 This is a Win Form app written in C#.
这是一个用C#编写的Win Form应用程序。
{
OdbcConnection cn = null;
String connectionString;
connectionString = "Driver={SQL Server};Server=" + cbxDataSources.Text +";Database=" + strDatabase + ";";
connectionString += "UID=" + textBoxUserName.Text + ";";
connectionString += "PWD=" + textBoxPassword.Text + ";";
cn = new OdbcConnection(connectionString);
return cn;
}
Thanks guys 多谢你们
You are using SQL Server authentication. 您正在使用SQL Server身份验证。
Windows authentication authenticates your connection with the Windows identity of the currently executing process or thread. Windows身份验证使用当前正在执行的进程或线程的Windows身份验证您的连接。 You cannot set a username and password with Windows authentication.
您无法使用Windows身份验证设置用户名和密码。 Instead, you set Integrated Security = SSPI.
相反,您设置Integrated Security = SSPI。
You have to connect using a Trusted Connection. 您必须使用可信连接进行连接。
2005: 2005年:
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;
2000: 2000年:
Driver={SQL Server};Server=myServerAddress;Database=myDataBase;Trusted_Connection=Yes;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.