2

I am trying to access LocalDB 2012 on my Windows 7 SP1 PC.

I have successfully installed LocalDB and started the instance using the command line, and it is currently running.

However, when I attempt to connect to this LocalDB instance using SQL Server Management Studio (SSMS), I receive the following error.

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: 26 - 
Error Locating Server/Instance Specified) 
(.Net SqlClient Data Provider)

I have verified the following configurations, and they seem to be working correctly as mentioned in the Link

  • TCP port is enabled.
  • SQL Server Configuration Manager is installed.
  • SQL Browser service is running.
  • Port 1433 is open.

Also note that I have tried connecting using the following instance names, but without success:

I have attempted to log in using Windows Authentication.

(localdb)\v11.0 
(localdb)\mssqllocaldb

Given all of this, what could be the cause of the issue.? How can I solve this issue?

2 Answers 2

3

Just a quick reminder that SQL Server 2012 is no longer supported.

+---------------------------+--------------+---------------------+-------------------+
|          Listing          |  Start Date  | Mainstream End Date | Extended End Date |
+---------------------------+--------------+---------------------+-------------------+
| Microsoft SQL Server 2012 | May 20, 2012 | Jul 11, 2017        | Jul 12, 2022      |
+---------------------------+--------------+---------------------+-------------------+

*Reference: Microsoft SQL Server 2012 (Microsoft Learn | Lifecycle)**

Looking at the Learn Documentation for SQL Server Express LocalDB you will find the following information:

(emphasis mine)

LocalDB installation copies a minimal set of files necessary to start the SQL Server Database Engine. Once LocalDB is installed, you can initiate a connection using a special connection string. When you connect, the necessary SQL Server infrastructure is automatically created and started, enabling the application to use the database without complex configuration tasks. Developer Tools can provide developers with a SQL Server Database Engine that lets them write and test Transact-SQL code without having to manage a full server instance of SQL Server.

Scrolling down further you will find the following information:

Automatic instances of LocalDB are public.

and

Named instances of LocalDB are private.

So you have to know if your instance was created as a named (private) instance or as an automatic (public) instance.

If you created an automatic instance, which is a shared instance, then the connection string should be similar to the name provided in the article:

(emphasis mine)

For example, to connect to a shared instance of LocalDB named AppData, use a connection string such as (localdb)\.\AppData as part of the connection string.

Please note the additional \.\ in the connection sting.

If this doesn't work then query your localdb instance with the following command to retrieve the named pipe connection string:

REM Gather information about the instance of LocalDB
"C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SqlLocalDB.exe" info LocalDBApp1

Enter the correct name of your localdb instead of LocalDBApp1.

This will return a set of information similar to the following:

+--------------------+-----------------------------------------+
|      Category      |                  Value                  |
+--------------------+-----------------------------------------+
| Name               | LocalDBApp1                             |
| Version            | <Current version>                       |
| Shared name        | ""                                      |
| Owner              | <Your Windows user>                     |
| Auto create        | No                                      |
| State              | Running                                 |
| Last start time    | <Date and time>                         |
| Instance pipe name | np:\\.\pipe\LOCALDB#F365A78E\tsql\query |
+--------------------+-----------------------------------------+

The instance pipe name is what you would use in the Server portion of the SSMS login box.

np:\\.\pipe\LOCALDB#F365A78E\tsql\query

Good luck.

0

I tried connecting using the instance pipe name and it worked.

np:\\.\pipe\LOCALDB#F365A78E\tsql\query

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.