9

I'm workig on a web app which is using

SQL Server Express (Microsoft SQL Server 2016 (SP1) (KB3182545) - 13.0.4001.0 (X64) Oct 28 2016 18:17:30 Copyright (c) Microsoft Corporation Express Edition (64-bit) on Windows 10 Pro 6.3 (Build 18362: )).

The web app is using connection string to connect to DB. After searching for a few days for a proper connection string format I managed to find the format, using method described by Nik in this blog post and it is:

Data Source = np:\\.\pipe\LOCALDB#A9DE3E14\tsql\query; Initial Catalog = MyDataBaseCatalog; User ID = myuser; Password=mypassword;

Everything was working fine yesterday, but today it stopped. I discovered that the service name has changed to:

LOCALDB#B87CB983

After replacing the instance name with the new service name in the connection string the web app works well, but it's not an acceptable solution.

Can you tell me why the instance name is changing, is it any Express version limitation? How can configure the name to be permanent?

17

This app isn't using the regular SQL Server Express Edition. Express Edition runs as a service such that you'd see it in the Services control panel (on Windows), and there would be a stable instance name, as you're expecting.

This service you're connecting to uses the (confusingly named) SQL Server Express LocalDB. This is often referred to as just "LocalDB" to reduce the confusion of the name overlap. LocalDB runs in process--that is, it isn't a service, but is started up by the app that uses is.

LocalDB supports a number of configurations, depending on how the application is intended to be accessed. Check out the section in the docs titled "Automatic and Named Instances" as well as the section titled "Shared Instances of LocalDB".

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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