[英]Unable to connect To the SQL server using the given connection String (using C# windows Application)
I am helping my friend in his college final year project, Its an C# application in a client machine and it uses SQL server in the windows server 2008 environment. 我正在他的大学期末项目中帮助我的朋友,它是客户端计算机中的C#应用程序,它在Windows Server 2008环境中使用SQL Server。
VM ware environment: VM Ware环境:
3 clients(windows 7) and 1 SQL database (in windows 2008) 3个客户端(Windows 7)和1个SQL数据库(Windows 2008)
The connection between he server and the client is working, the port 1433 for SQL is open and its listening. 服务器和客户端之间的连接正在工作,SQL的端口1433已打开并且正在侦听。
When I try to run the program am getting the following error. 当我尝试运行该程序时,出现以下错误。
This is the connection string which am using. 这是正在使用的连接字符串。
cn = new SqlConnection(@"Data Source=192.168.1.2,1433;Initial Catalog=Test;Integrated Security=True"); cn =新的SqlConnection(@“数据源= 192.168.1.2,1433;初始目录=测试;集成安全性= True”);
And i have also tried to refer this website for connection strings, but i don't know how it works. 而且我也曾尝试引用此网站的连接字符串,但我不知道它是如何工作的。
http://www.connectionstrings.com/sql-server-2008 http://www.connectionstrings.com/sql-server-2008
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN; 数据源= 190.190.200.100,1433;网络库= DBMSSOCN; Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword; 初始目录= myDataBase;用户ID = myUsername;密码= myPassword;
I am getting an error. 我收到一个错误。 Tried to give a simple username and password in the SQL server and tried it, still the same issue. 试图在SQL Server中提供一个简单的用户名和密码,并尝试了它,仍然是同样的问题。 please check the image. 请检查图像。 The Username and password which i used is the System login(windows authentication) 我使用的用户名和密码是系统登录名(Windows身份验证)
I just want to access the SQL server in the Windows 2008 machine. 我只想访问Windows 2008计算机中的SQL Server。
Where should i check the credentials for this connection string ? 我应该在哪里检查此连接字符串的凭据?
Thank you soo much for reading this patiently. 非常感谢您耐心阅读。
您可以访问Connectionstrings.com以获取有关连接字符串及其用法的更多信息。
Try removing the port from your connection string (1433 is the default SQL port): 尝试从连接字符串中删除端口(1433是默认的SQL端口):
cn = new SqlConnection(@"Data Source=192.168.1.2;Initial Catalog=Test;Integrated Security=True");
For a connection using sql authentication (which would eliminate trust issues between machines) use the following (replacing xxxx and yyyy with the appropriate user name and password): 对于使用sql身份验证的连接(这将消除机器之间的信任问题),请使用以下命令(用适当的用户名和密码替换xxxx和yyyy):
cn = new SqlConnection(@"Data Source=192.168.1.2;Initial Catalog=Test;Integrated Security=False; User=xxxx; Password=yyyy");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.