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. (I want to connect to a local data base):
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:
cn = new SqlConnection();
cn.ConnectionString = "Data Source=(local); Initial Catalog=XXX_amlak; User ID=sa; password=XXX";
cn.Open();