0

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.

Geeky Bird
  • 75
  • 9
  • 1
    take a look here : http://stackoverflow.com/questions/11278114/enable-remote-connections-for-sql-server-express-2012 – 2GDev Sep 12 '13 at 09:40
  • http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/ .....it's a fairly common problem with **tons** of *not only Google results* but also SO results. – Arran Sep 12 '13 at 09:40

2 Answers2

1

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

Rajesh Subramanian
  • 6,400
  • 5
  • 29
  • 42
0

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");
Plymouth223
  • 1,905
  • 1
  • 12
  • 22