3

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

frenchie
  • 51,731
  • 109
  • 304
  • 510
  • change the .\SQLEXPRESS for the entire server name. – Nudier Mena Jun 24 '12 at 00:27
  • @Nudier: where do I find this information? – frenchie Jun 24 '12 at 00:47
  • 1
    You should note that the database you've connected to in Visual Studio is not going to exist on your SQL Express instance. You should create the database in SQL Server (once you've managed to connect to it), and ***STOP*** using the "user instance" and "AttachDbFileName" settings. These are ridiculous and deprecated, and once you're connected you'll be back here asking why the updates you make in Management Studio don't reflect in Visual Studio and vice versa. The reason is they're two different databases. – Aaron Bertrand Jun 24 '12 at 00:52
  • No, I am asking where do I find the server name of sql server. I can't even connect to sql server! – frenchie Jun 24 '12 at 00:57
  • According to Visual Studio, the named instance is called `\SQLEXPRESS`. What @Nudier meant to suggest was to try `Your_Computer_Name\SQLEXPRESS` instead of `.\SQLEXPRESS`. – Aaron Bertrand Jun 24 '12 at 01:00
  • It occur with you chance name of installed instance of sqlserver. Verify name of instance. – Jones Jun 24 '12 at 01:10
  • @Ankit have you read the previous comments? Why would you suggest something tht's already been suggested? – Aaron Bertrand Jun 24 '12 at 13:16

1 Answers1

4

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.

Aaron Bertrand
  • 272,866
  • 37
  • 466
  • 490
  • I know this might sound weird but how do I start sql server, or check that it's running? – frenchie Jun 24 '12 at 01:01
  • Do you know where the Control Panel is? Under Administrative Tools, there is an applet called Services. In that list is an item called `SQL Server (SQLEXPRESS)`. If that doesn't say `Started`, you need to start it (you can do this by clicking the right-hand side of your mouse and selecting the `Start` option from the menu that appears). – Aaron Bertrand Jun 24 '12 at 01:04
  • ok, I'm in the Services part but there's no sql server listed. There's just sql server VSS writer – frenchie Jun 24 '12 at 01:05
  • Then how could Visual Studio possibly be connecting to it? Are you on the same machine where this connection string in Visual Studio works, or is that a different machine? Have you uninstalled SQL Server since the last time that worked? – Aaron Bertrand Jun 24 '12 at 01:06
  • Why is it not there? I just installed it. – frenchie Jun 24 '12 at 01:06
  • No idea, I wasn't watching you install it, so I have no idea what you did, sorry. – Aaron Bertrand Jun 24 '12 at 01:07
  • Go to Start->All Programs->Microsoft SQL Server->Configuration Tools->SQL server configuration Manager .Under SQL Server Services you will see your sql server instance – praveen Jun 24 '12 at 01:12
  • @praveen: unfortunately, it's not there; just added screenshot – frenchie Jun 24 '12 at 01:18
  • 1
    Then you need to actually install SQL Server Express. It doesn't get there by magic; perhaps I misunderstand how Visual Studio can use an instance name like that if it doesn't even exist. – Aaron Bertrand Jun 24 '12 at 01:23
  • It's already installed; I went through the SQL server Setup. Apparently the problem is that it's not even starting and not listed in the services applet. Not sure what to do now. Nice article BTW! – frenchie Jun 24 '12 at 01:35
  • I don't know what else to tell you. If SQL Server isn't in the Control Panel or the Configuration Manager, then it's not installed. – Aaron Bertrand Jun 24 '12 at 01:38
  • But I do see a list of about 10-15 program names related to SQL server 2012 in the Uninstall or Change a program window. – frenchie Jun 24 '12 at 01:44
  • But none of them are SQL Server. If you have a BMW jacket and a BMW keychain, it doesn't mean there's a BMW in the driveway. – Aaron Bertrand Jun 24 '12 at 01:55
  • ok, you pointed me towards the solution: I had downloaded Sql Server Express with Tools. I went back to the download page and downloaded Express Only and that did it. Why the "With Tools" option didn't also install sql server itself is a mystery... Thanks for your time! – frenchie Jun 24 '12 at 02:08
  • 2
    The only way With Tools wouldn't have worked is if you didn't choose the database engine services as part of setup. I have successfully installed SQL Express using he With Tools installer. – Aaron Bertrand Jun 24 '12 at 02:16