Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2012 connection string: can no longer find Server?

I just installed VS2012 pro RC and SQL server Express 2012. I go to run my app and I get this error:

The Data Source value in the connection sting specifies an instance of SQL Server that is not installed. To resolve this issue, you can either choose to install the matching instance of SQL Server or modify the Data Source value in the connection string.

I used VS2012 Developer preview for a long time and it used to work just fine. This is the connection string that's in the web.config file:

<add name="MySiteDBConnectionString"
     connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MySiteDB.mdf;Integrated Security=True;User Instance=True"
     providerName="System.Data.SqlClient"/>

When I go to Management Studio, I get the error message below. When I go to browse for servers, the list is empty.

enter image description here

Where's the problem and how do I solve it?

Thanks. enter image description here

like image 224
frenchie Avatar asked Mar 11 '26 13:03

frenchie


1 Answers

You need to make sure the SQL Server service is running. Visual Studio might be spinning it up for you when you establish a connection using web.config and that silly AttachDbFileName feature. Check your Services Control Panel applet and make sure that SQL Server (SQLEXPRESS) is running. If it isn't running, start it.

While you're there, it can't hurt to make sure the SQL Browser service is running.

It also can't hurt to use the proper case. If the instance is called SQLEXPRESS then don't call it SqlExpress or SQLExpress. I've never heard of this breaking connectivity, but be consistent. You might also try other variations just in case:

(local)\SQLEXPRESS
localhost\SQLEXPRESS
127.0.0.1\SQLEXPRESS
Your_Computer_Name\SQLEXPRESS

You should also verify what connection protocols are enabled for this instance. Go to Start > Programs > SQL Server > Configuration Tools > Configuration Manager, expand SQL Server Network Configuration, and highlight Protocols for SQLEXPRESS - on the right you should see Shared Memory, Named Pipes, TCP/IP. Which of these are enabled?

EDIT

You should download SQL Server 2012 Express from here. Install it. Then create a database. Point Visual Studio at that database. Stop, and I really mean STOP, using the User Instance and AttachDbFileName features. These things are supposed to make development easier but at the end of the day they do little but make development a royal pain in the rear.

Another option is to use SqlLocalDb for local development. Last month I wrote a thorough "Getting Started" tutorial that may help.

like image 68
Aaron Bertrand Avatar answered Mar 14 '26 01:03

Aaron Bertrand



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!