0
votes

In an app I've developed in VB.NET and I use a SQL Server LocalDB. The app downloads and installs SQL Server if it doesn't exist on the user's machine and it creates a local instance if there isn't one running at least v14.

On my development machine it works well. Every time the app opens I test the connection using this connection string:

Data Source=(LocalDB)\MSSQLLocalDB15;Integrated Security=True;Connect Timeout=30

But when I'm testing the app on a virtual machine running a fresh copy of Windows 10, the app cannot connect using the Instance Name (MSSQLLocalDB15). I've tried using a "." in the servername, leaving out the server name, and localhost in the servername. It does work using the Named Pipe. However every time the instance stops and starts that changes - I'd prefer not to find out the Named Pipe name changed after a 60-second timeout has been exceeded.

I found one question that seems to be the same problem: Can't connect to Localdb but can using namedpipe

However I don't see any errors in the Event Viewer as that author does. In addition, I'm hesitant to change the timeout to indefinite when I know that letting the instance terminate works fine on my development machine. I expect users may leave the application on overnight and I don't want to cause performance problems if they aren't focused on my app. (I also don't know how to implement the suggestions in that answer, although that's secondary for me)

What could be the difference between my dev computer and the virtual machine? I have Visual Studio 2019 and SQL Server Express installed on my dev computer - could one of them have installed something that helps me connect to a LocalDB?

Added: This is from my test machine. You can see that MSSQLLocalDB is "not created" inexplicably, and MSSQLLocalDB15 is running fine. I do have one lead suggesting that the difference between my dev machine and my test machine is that the dev user is an admin and the test user is not.

enter image description here

1
This is often because TCP communication for SQL server is not enabled by defaulterikkallen
I was under the impression the LocalDB didn't use TCP/IP. How would I do that?Scott

1 Answers

1
votes

Try to use "MSSQLLocalDB" as instance name instead of "MSSQLLocalDB15". MSSQLLocalDb is the standard instance that is automatically created during LocalDb setup. If you want to use "MSSQLLocalDB15" you have to create it manually using

sqllocaldb c MSSQLLocalDB15

at the command line. Also you could use

sqllocaldb v

To check what LocalDb instances currently exist ... I gues you have MSSQLLocalDB15 on your dev machine but not on your test virtual machine.