SQL Server Express 2012 Error: Cannot connect to Local DB

AM0 picture AM0 · Dec 10, 2013 · Viewed 12.2k times · Source

I have installed Sql Express 2012 version. I installed Local Db separately. i can see its installed when I click on "Installed Sql Server discovery report". However, I cannot connect to it using Sql Server Management Studio or Microsoft Visual Studio 2012 Professional Edition. I get the error:

"The attempt to attach to the database failed with the following information: 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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details."

In Windows Event viewer I see several of following errors with different regsistry keys each time:

"The DataDirectory registry value is missing in the LocalDb instance registry key:{-----}"

I checked in regsitry values for local db in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MicrosoftSQL Server Local DB and there's only one entry "Installed Version". I have gone through several posts which state solution for the above error and have done almost everything they have suggested but still can't get localDb to work.

I'd appreciate any help that one can provide in order to solve this issue.

UPDATE:

Using Command Line Interface I verified that localDb v11.0 is installed. However, the command sqlLocalDb info v11.0 gives error:"The automatic instance "v11.0" is not created. If I try to create one it gives another error:"Unexpected error occured inside a localDb instance API method call."

Answer

Rahul Tripathi picture Rahul Tripathi · Dec 10, 2013

You may try to use SQL Server Authentication. Also make sure that your SQL service is running.

Also you may try to delete the following registry:

HKEY_USERS\.DEFAULT\Software\Microsoft\Microsoft SQL Server\UserInstances\[GUID_FROM_EVENT_LOG]

You may also check Getting Started with SQL Server 2012 Express LocalDB