Click here to Skip to main content
15,905,071 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to connect to the Remote Database using Connection String in C#.net
I want to connect a remote database using Sql Connection String in C#.net, I am trying it to do, but failed to connect.
C#
SqlConnection connect = new SqlConnection("server=SERVER\\MSSQLSERVER2008; Database = DataConverter; Trusted_Connection = True");

getting the following error
"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified) "

ienabled TCP/IP in the sqlserver. Does it mean that remote system and local system not in network?
Posted
Updated 31-Oct-11 3:59am
v5

Check the following link to see different options for connecting to SQL 2008:

http://www.connectionstrings.com/sql-server-2008[^]
 
Share this answer
 
Check

1. Whether th SQL server can accept remote connection ?
In your SQL server management studio right click on the database and select "properties" and the click on "connection" in the left hand side and make you the check box "Allow remote conenctions to this servers" is ticked


2. Whether you can ping ?
ping SERVER
in the command prompt
3. Whether your instance name is correct ?
4. Whether the ports are opened on the firewalls to connect the SQL server

http://support.microsoft.com/kb/287932[^]
 
Share this answer
 
v2
SqlConnection connect = new SqlConnection("Data Source=SERVER1\\MSSQLSERVER2008;Initial Catalog=DBname;User ID=sa;Password=sa");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900