0
votes

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.

VM ware environment:


3 clients(windows 7) and 1 SQL database (in windows 2008)

The connection between he server and the client is working, the port 1433 for SQL is open and its listening.

When I try to run the program am getting the following error.

Error Message when i run the SQL code in the application on button-click

This is the connection string which am using.

cn = new SqlConnection(@"Data Source=192.168.1.2,1433;Initial Catalog=Test;Integrated Security=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

Data Source=190.190.200.100,1433;Network Library=DBMSSOCN; Initial Catalog=myDataBase;User ID=myUsername;Password=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. please check the image. The Username and password which i used is the System login(windows authentication)

Error message when i use the username and password

I just want to access the SQL server in the Windows 2008 machine.

Where should i check the credentials for this connection string ?

Thank you soo much for reading this patiently.

2
blog.sqlauthority.com/2009/05/21/… .....it's a fairly common problem with tons of not only Google results but also SO results. - Arran

2 Answers

0
votes

Try removing the port from your connection string (1433 is the default SQL port):

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):

cn = new SqlConnection(@"Data Source=192.168.1.2;Initial Catalog=Test;Integrated Security=False; User=xxxx; Password=yyyy");
1
votes

You can go to Connectionstrings.com to get more information on connection strings and its usages.