登录失败的用户。用户未与受信任的SQL Server连接关联。 C# [英] Login failed user. The user is not associated with a trusted SQL server connection. C#
问题描述
使用c#windows应用程序登录失败用户的LAN上的SQL Server 2005。用户与可信的sql server连接无关。
.........
我试图使用以下代码建立连接使用visual studio 2013 / c#的SQL
服务器数据库2005。但是,当我执行代码时,我收到以下
错误:
登录失败的用户。用户没有与受信任的sql server连接相关联。
。
我的服务器上的数据库它在microsoft访问项目中工作但是没有工作
当我使用c#。
将我的用户域名更改为admin时,它已经工作。
我尝试过:
//字符串连接字符串=数据源= xxx.xxx,1433;初始目录=数据库;集成Security = SSPI; User ID = user1; Password = 123456;
// string connectionString =Data Source = xxx.xxx; Initial Catalog = Database2; Integrated Security = True;
// string connectionString =Data Source = xxx.xxx; Database = Database2; User Id = user1; Password = 123456; Persist Security Info = False;
// string connectionString = Provider = SQLNCLI; Server = xxx.xxx; Database = Database2; Trusted_Connection = yes;;
// string connectionString =Provider = SQLNCLI; Server = xxx.xxx; Database = Database2; Trusted_Connecti on = yes; MARS Connection = True;;
// string connectionString =Provider = sqloledb; Data Source = xxx.xxx,1433; Network Library = DBMSSOCN; Initial Catalog = Database2; User ID = user1;密码= 123456;;
string connectionString =Provider = sqloledb; Data Source = xxx.xxx; Network Library = DBMSSOCN; Initial Catalog = Database2; User ID = user1; Password = 123456 ;;
SQL Server 2005 over LAN with c# windows application- login failed user. the user is not associated with a trusted sql server connection.
.........
I am attempting to use the following code to establish a connection to a SQL
Server database 2005 by using visual studio 2013/c#. However, when I execute the code, I receive the following
error:
login failed user . the user is not associated with a trusted sql server connection.
.
my database on the server it is work in microsoft access project but is not worked
when i Used c#.
when change my user domain to admin it is worked.
What I have tried:
//string connectionString = "Data Source=xxx.x.x.x,1433;Initial Catalog=Database;Integrated Security=SSPI;User ID=user1;Password=123456";
//string connectionString = "Data Source=xxx.x.x.x;Initial Catalog=Database2;Integrated Security=True";
// string connectionString = "Data Source=xxx.x.x.x;Database=Database2;User Id=user1;Password=123456;Persist Security Info=False";
// string connectionString = "Provider=SQLNCLI;Server=xxx.x.x.x;Database=Database2;Trusted_Connection=yes;";
// string connectionString = "Provider=SQLNCLI;Server=xxx.x.x.x;Database=Database2;Trusted_Connection=yes;MARS Connection=True;";
// string connectionString = " Provider=sqloledb;Data Source=xxx.x.x.x,1433;Network Library=DBMSSOCN;Initial Catalog=Database2;User ID=user1;Password=123456;";
string connectionString = " Provider=sqloledb;Data Source=xxx.x.x.x;Network Library=DBMSSOCN;Initial Catalog=Database2;User ID=user1;Password=123456;";
推荐答案
嗨Jon,
您可以使用这种方式
标准安全
服务器= myServerAddress;数据库= myDataBase;用户ID = myUsername;
密码= myPassword;
可信连接
Server = myServerAddress; Database = myDataBase; Trusted_Connection = True;
与SQL Server实例的连接
服务器选项中使用的服务器/实例名称语法对于所有SQL Server连接字符串都是相同的。
Server = myServerName \ myInstanceName ; Database = myDataBase; User Id = myUsername;
Password = myPassword;
您可以参考https://www.connectionstrings。 com / sql-server /求助。
如果不能帮助你请复制你的代码,以便我们可以调试它。
Hi Jon,
you can use either of this way
Standard Security
Server=myServerAddress;Database=myDataBase;User Id=myUsername;
Password=myPassword;
Trusted Connection
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
Connection to a SQL Server instance
The server/instance name syntax used in the server option is the same for all SQL Server connection strings.
Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;
Password=myPassword;
you can refer "https://www.connectionstrings.com/sql-server/" for help.
if it will not help you please copy your code so we can debug for it.
>
这篇关于登录失败的用户。用户未与受信任的SQL Server连接关联。 C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!