简体   繁体   English

无法使用给定的连接字符串连接到SQL Server(使用C#Windows应用程序)

[英]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. 当我尝试运行该程序时,出现以下错误。

我在按钮上单击应用程序中运行SQL代码时出现错误消息

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.

相关问题 C#Windows应用程序:使用Windows身份验证连接到远程SQL Server 2008的连接字符串 - C# Windows application: connection string to connect to remote sql server 2008 using windows authentication 无法通过Windows身份验证使用连接字符串连接到SQL Server - Unable to connect to SQL Server using a connection string with Windows authentication 无法从Windows应用程序C#连接到SQL Server数据库 - unable to connect to sql server database from windows application c# 如何使用 C# 中的连接字符串将 SQL 服务器从客户端连接到服务器 PC - How to Connect SQL server from client to Server PC using Connection string in C# 连接字符串,用于使用其他Windows帐户连接SQL Server - Connection String to connect a SQL Server using another windows account 有没有一种方法可以使用网络服务帐户将Windows C#应用程序连接到SQL Server - Is there a way to connect Windows C# Application to SQL Server using a Network Service Account 无法使用C#连接到SQL Server数据库 - Unable to connect to SQL Server database using C# 如何使用C#中的IP地址将应用程序连接到SQL Server? - How to connect an application to a SQL Server using IP Adress in C#? C# WPF 应用程序连接到 SQL SERVER 使用 MSA - C# WPF Application Connection to SQL SERVER using MSA 无法使用C#Web项目连接到SQL Server 2008 r2,错误:连接字符串无效 - Unable to connect to SQL Server 2008 r2 with C# web project, Error: Connection string not valid
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM