简体   繁体   English

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

[英]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.

相关问题 使用Windows身份验证进行SQL Server的连接字符串不起作用 - My connection string using Windows authentication for SQL Server doesn't work C#Windows应用程序:使用Windows身份验证连接到远程SQL Server 2008的连接字符串 - C# Windows application: connection string to connect to remote sql server 2008 using windows authentication sql连接字符串Windows身份验证c#winforms(未集成) - sql connection string windows authentication c# winforms (not integrated) 在C#中使用SQL Server身份验证的连接字符串 - Connection string using SQL Server authentication in C# C#SQL Server CE-更新将不起作用 - C# SQL Server CE - Update won't work C#程序使用我的Windows AD身份验证而不是我编码到其中的连接字符串连接到我的数据库。 为什么? - C# Program is using my Windows AD authentication to connect to my database instead of the connection string I coded into it. Why? C#-SQL连接无法关闭 - C# - SQL Connection won't close SQL Server连接C#:到数据库的身份验证Windows使用计算机名代替 - SQL Server connection C# : Authentication Windows to database uses computer name instead C#SQL Server身份验证字符串 - C# SQL Server authentication string SQL Server 2012连接字符串在经典ASP(VBScript)中工作正常,但在ASP.NET C#项目中不起作用 - SQL Server 2012 connection string works fine in classic ASP (VBScript) but doesn't work in ASP.NET C# project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM