繁体   English   中英

为什么到SQL Server的c#连接字符串不能与Windows身份验证一起使用?

[英]Why won't my c# connection string to a SQL server work with Windows authentication?

为什么我与SQL Server的连接字符串不能与Windows身份验证一起使用? sql用户工作正常,acme \\ administrator或administrator@acme.com无法正常工作。 这是一个用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;
    }

多谢你们

您正在使用SQL Server身份验证。

Windows身份验证使用当前正在执行的进程或线程的Windows身份验证您的连接。 您无法使用Windows身份验证设置用户名和密码。 相反,您设置Integrated Security = SSPI。

您必须使用可信连接进行连接。

2005年:

Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;

2000年:

Driver={SQL Server};Server=myServerAddress;Database=myDataBase;Trusted_Connection=Yes;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM