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

14,040

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.

Share:
14,040
frenchie
Author by

frenchie

Started programming when I was 10. Never made it my profession but always programmed, mostly with Excel VBA for finance, and for some simple front-end web design in the early 2000's (ie. no jquery back then, what a pain it was with DHTML). One day, I get the idea of outsourcing the web development of my start-up: total cacacacacacacafukkkk! So: from VBA to C# .NET and Javascript in 5,000 pages of programming books, and lots of Stackoverflow! I think asking dumb questions is a smart way to learn. And as an internet entrepreneur, I've learned that what matters most is not knowing how to program but knowing what to program: discover the goyaPhone at www.goyaphone.eu

Updated on June 04, 2022

Comments

  • frenchie
    frenchie almost 2 years

    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
    frenchie almost 12 years
    I know this might sound weird but how do I start sql server, or check that it's running?
  • Adir D
    Adir D almost 12 years
    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).
  • frenchie
    frenchie almost 12 years
    ok, I'm in the Services part but there's no sql server listed. There's just sql server VSS writer
  • Adir D
    Adir D almost 12 years
    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?
  • frenchie
    frenchie almost 12 years
    Why is it not there? I just installed it.
  • Adir D
    Adir D almost 12 years
    No idea, I wasn't watching you install it, so I have no idea what you did, sorry.
  • praveen
    praveen almost 12 years
    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
  • frenchie
    frenchie almost 12 years
    @praveen: unfortunately, it's not there; just added screenshot
  • Adir D
    Adir D almost 12 years
    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.
  • frenchie
    frenchie almost 12 years
    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!
  • Adir D
    Adir D almost 12 years
    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. <shrug>
  • frenchie
    frenchie almost 12 years
    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.
  • Adir D
    Adir D almost 12 years
    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.
  • frenchie
    frenchie almost 12 years
    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!
  • Adir D
    Adir D almost 12 years
    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.