8

working with visual studio 2012 ultimate everytime i create a new dependency graph i get this error :

Unable to connect to the specified database.

An exception occurred attempting to connect to a database using the following connection string:
Data Source=(LocalDB)\v11.0;AttachDbFilename=;Initial Catalog=master;
Integrated Security=True;Enlist=False;
Asynchronous Processing=True;MultipleActiveResultSets=True;Connect Timeout=30.

Check that the specified SQL Server instance exists and the service is running.

my solution get build properly and my connection string is something like this :

<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.;Initial Catalog=JewelryStore;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
</connectionStrings>

what is the problem here?

Amir Jalali
  • 3,132
  • 4
  • 33
  • 46

2 Answers2

18

Your issue is likely a problem with your localDB instance at:

%localappdata%\Microsoft\Microsoft SQL Server Local DB\Instances\v11.0

I had the same problem because when I installed VS12 my computer was not in a domain and I recently joined it to a domain and my user account does not have permissions to the SQL DB.
To fix the issue I ran

sqllocaldb stop "v11.0" -k
sqllocaldb delete "v11.0"
sqllocaldb create "v11.0" 
sqllocaldb start "v11.0"

I then restarted VS 2012 and my local DB is now usable and the Dependency Graph is now created

Todd Carter
  • 879
  • 7
  • 20
  • I don't have localDB installed on my computer. is there anyway so that i can use sql server 2008 r2 instead of localDB. my connection string is set appropriately but i still get error. – Amir Jalali Oct 29 '12 at 19:03
  • Fairly certain it has to use localdb, which I believe is a Pre-req install for VS – Todd Carter Nov 05 '12 at 04:28
  • you mean there isn't anyway to use sql server instead of localdb? – Amir Jalali Nov 05 '12 at 07:18
  • No there does not appear to be that option – Todd Carter Dec 01 '12 at 13:43
  • This answer also fixed the same issue I was having with Visual Studio 2013 Ultimate. Uninstall/Reinstall of LocalDB did not work, but these commands got it working. – stricq Dec 31 '13 at 17:27
  • The 3rd command fail for me with this: `Creation of LocalDB instance "v11.0" failed because of the following error: The specified LocalDB version is not available on this computer.` I managed to create a localDB with v12.0 instead but don't know where to change this connection string. – Vitor Canova Oct 13 '15 at 14:26
  • I needed to install the v11.0 version again. Found [here](https://www.microsoft.com/betaexperience/pd/SQLEXPCTAV2/enus/default.aspx) – Vitor Canova Oct 13 '15 at 18:44
0

After the suggested solution I still had the error. I had to execute Visual Studio as Administrator, this way solve the problem.

Alessandro
  • 153
  • 1
  • 1
  • 8