Can not connect to localDB through ODBC

Moshe Plotkin 21 Reputation points
2022-08-23T21:29:45.067+00:00

B"H

Everything was working fine until I made a few changes (including installing VS 2022), and I can't figure out which change caused the problems.

I connect an access front end to a local SQL server through ODBC. I do this on a number of computers (then sync the databases through azure). Some are regular SQL Express instances, and some are LocalDB.

The computer that stopped working is one that uses LocalDB. The entire instance got corrupted. After I was able to delete the instance and recreate it. I can now connect through Azure Data Studio, and Visual Studio, etc. I just can't connect through ODBC. I've tried all of the different drivers including SQL Server Native Client 11.0, ODBC Driver 17 for SQL Server, and more. None of them work.

What does work, is if I use the named pipe url directly in the server section of the ODBC setup. So instead of putting (localdb)\MSSQLLocalDB I put np:\.\pipe\LOCALDB#D26172B4\tsql\query. That does work, but the instance id in that URL changes every time the instance starts. So every time the computer restarts we need to create a new ODBC connection. That is not a maintainable solution.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,808 questions
{count} votes

Accepted answer
  1. YufeiShao-msft 7,061 Reputation points
    2022-08-24T08:53:22.78+00:00

    Hi @Moshe Plotkin ,

    Please check out this thread, it mentioned that this issue seems to be prevalent in Localdb v2017 and later versions
    https://dba.stackexchange.com/questions/249097/cant-connect-to-sql-server-2017-local-db-shared-instance

    You can try to install the cumulative updates for SQL Server:
    KB5003342 - FIX: SQL Server Express LocalDB can't start or connect to shared instances of SQL Server Express LocalDB 2019 or 2017

    -------------

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful