Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi,
Please solve my problem
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

My pcname:bhargava-f794cb
Instace name:MSSQLSERVER

what is the datasource name
C#
SqlConnection conn = new SqlConnection("Data Source=MSSQLSERVER;Initial Catalog=OnlineLibrary;Integrated Security=True");
Posted
Updated 18-Nov-17 17:28pm
v2
Comments
Dave Kreskowiak 3-Mar-12 0:12am    
Which edition of SQL Server are you using?? Express or what??

Try setting up a connection in VS with the Server Explorer pane:
1) Open Server Explorer.
2) Right click "Data connections" and select "Add connection"
3) In the dialog that follows, select your DataSource, and database, specify the security info, and press the "Test connection" button.
4) When the connection works, press "OK"
5) highlight your database in the Server Explorer pane, and look at the Properties pane. A working example of the connection string will be shown, which you can copy and paste into your app or config file.
 
Share this answer
 
Comments
Member 8634349 3-Mar-12 11:14am    
Thanks....
VB
SqlConnection conn = new SqlConnection("Data Source=bhargava-f794cb\SQLEXPRESS;Initial Catalog=OnlineLibrary;Integrated Security=True");
 
Share this answer
 
Comments
Member 8634349 3-Mar-12 10:21am    
I TRY this but it shown error:

"Unrecognise escape sequence"

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