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
How to Connect to SQL Server 2008 with VS 2010
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Mahesh ChandRank #1 · 393K pointsPosted May 1, 2011, 9:23 AM EDT
natchaya khamkuna20 pointsPosted May 1, 2011, 10:25 AM EDT
natchaya khamkuna20 pointsPosted May 1, 2011, 10:34 AM EDT
I got it now , Thank anyway..
FoonMod
Abhimanyu K VatsaRank #14 · 51.6K pointsPosted May 2, 2011, 3:48 AM EDT
(i) open the Server Explorer and refresh the databases
(ii) if you get any error at refresh time then most probably your system has some temp. files or say bugs which is creating error
(iii) if database refreshes well then proceed next
(iv) add another .aspx page and switch it in design view
(v) drag the table from db explorer on web form
(vi) it automatically will create a new connectionString in your config file or already exist then override it.
(vii) now use that connectionString name in your apps
hope this helps