0
votes

With LocalDB 2016 I could share a named instance and then I could -

  1. login to the shared instance through SSMS with Server Name - (LocalDB)\.\SharedName
  2. access a database from my .NET Core app with connection string -
"Server=(LocalDB)\\.\\SharedName;Database=MyDB;Trusted_Connection=True;"
  1. host the app in a Windows Service running under a different user account and access a database with above connection string

Recently, I uninstalled the LocalDB 2016 and installed LocalDB 2019. I created a new instance and shared it as before, but I cannot do anything listed above.

  • When I try to login through SSMS, I meet with the following message -

enter image description here

  • When I try to access the database from my .NET Core app, an exception says -

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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

  • and similar message in Event Viewer with Window Service hosting.

I tried LocalDB 2017 too. That also gives the same result.

Is there something new with LocalDB 2017/2019 when sharing an instance which I might be missing? I checked the documentation(Connect to a shared instance of LocalDB) but couldn't find any helpful clue.

How do I solve this issue? Thanks.

1
Just use SQL Express instead - ErikEJ

1 Answers

-1
votes

https://www.c-sharpcorner.com/article/resolve-error-40-could-not-open-a-connection-to-sql-server/ try refer this. check your server name. ( your connect sql server login user name)

"Data Source=your server name;Initial Catalog=yourdb;User ID=youruser;Password=yourpassword;"