簡體   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