datastation icon indicating copy to clipboard operation
datastation copied to clipboard

Unable to connect SQL Server LocalDB

Open fortunewalla opened this issue 2 years ago • 5 comments

Is there support for MS SQL Server LocalDB?

SQL Server LocalDB Instance : (localdb)\MSSQLLocalDB

So I entered the host as (localdb)\MSSQLLocalDB with pubs as the database. (This hostname works in Excel when connecting using SQL Server connection)

select 1+2;

It gives this error.

Error evaluating panel:
[INFO] 2023-08-20T22:49:28 DataStation Runner (Go) 0.11.0
[INFO] 2023-08-20T22:49:28 Evaling database panel: Untitled panel #1
[INFO] 2023-08-20T22:49:28 Failed to eval: parse "sqlserver://user:pass@(localdb)\\MSSQLLocalDB:1433?database=pubs": invalid character "\\" in host name

BTW it works with another similar software called DatabaseBrowser

image

fortunewalla avatar Aug 20 '23 17:08 fortunewalla

Maybe try replacing (localdb)\MSSQLLocalDB with 127.0.0.1?

eatonphil avatar Aug 21 '23 12:08 eatonphil

Maybe try replacing (localdb)\MSSQLLocalDB with 127.0.0.1?

Thanks for trying to help out but It gives the following error.

Error evaluating panel:
[INFO] 2023-08-22T18:19:13 DataStation Runner (Go) 0.11.0
[INFO] 2023-08-22T18:19:13 Evaling database panel: Untitled panel #1
[INFO] 2023-08-22T18:19:16 Failed to eval: unable to open tcp connection with host '127.0.0.1:1433': dial tcp 127.0.0.1:1433: connectex: No connection could be made because the target machine actively refused it.

This would make it use TCP connection instead of ODBC connection.

As per the original error, it cannot parse the \ slash in the server name properly. I think? 🤔

fortunewalla avatar Aug 22 '23 12:08 fortunewalla

DataStation just passes the connection string along to the underlying library. So you could ask this question in https://github.com/denisenkom/go-mssqldb (the library used for connecting to SQL Server) and maybe they'll know!

eatonphil avatar Aug 22 '23 16:08 eatonphil

hopefully a resolution will be found by someone. 🤞🏼

fortunewalla avatar Aug 26 '23 12:08 fortunewalla

So as per the suggestion given on this page: https://weblogs.asp.net/jongalloway/sql-force-the-protocol-tcp-named-pipes-etc-in-your-connection-string

I tried with the connection string Server=np:(localdb)\MSSQLLocalDB

It now gives a different error where it parses everything after : as a port number.

Error evaluating panel:
[INFO] 2023-08-27T16:40:05 DataStation Runner (Go) 0.11.0
[INFO] 2023-08-27T16:40:05 Evaling database panel: Untitled panel #1
[INFO] 2023-08-27T16:40:05 Failed to eval: parse "sqlserver://@Server=np:(localdb)\\MSSQLLocalDB?database=pubs": invalid port ":(localdb)\\MSSQLLocalDB" after host

P.S. I'm posting it here also for future use by someone. 😇

fortunewalla avatar Aug 27 '23 11:08 fortunewalla