Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SQL
Hello
I installed SQL Server 2008 R2 and Visual Studio 2010 in my win7 32 bit. They were installed correctly. And each works well alone. But when I want to connect to SQL Server Management Studio from visual Studio I get this error:

SQLException was unhandled 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)


This is my code for connection:

C#
cn = new SqlConnection();
cn.ConnectionString = "Data Source=(local); Initial Catalog=XXX_amlak; User ID=sa; password=XXX";
cn.Open();
Posted

If viewing SQL Server Configuration Manager you only see the SQLEXPRESS instance name, then the Standard edition you "installed" did not get installed properly or at all. If in the install of the Standard Edition you just clicked through the wizard it probably installed as the default instance. In this case you should see a MSSQLSERVER instance name in Configuration Manager, or you can check in the Window Services applet (@ Run prompt > services.msc).
 
Share this answer
 
try to have a connection using "Server Explorer" and check if able to connect. If fine just copy the connection string from there
 
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