natchaya khamkuna

natchaya khamkuna

  • NA
  • 31
  • 23.5k

How to Connect to SQL Server 2008 with VS 2010

May 1 2011 11:18 AM
I need help.
  I use Visual studio 2010 and CSharp  try to connect to SQL Server (Developer edition install into my computer) 

string conStr = "Data Source=.\\MSSQLSERVER;Initial Catalog=AdventureWorks;Integrated Security=True";

SqlConnection conn = new SqlConnection(conStr);
conn.Open();

but it has error like below.
---------------------
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)
-------------------------
I also enable the  remote server connection option.

So, please help suggest me if you can.

Thank you

foonMod


Answers (4)