Can't get local DB to work with application when on another PC

0

So I have this application I wrote as a little project for work. It uses a single database table that was set up within Visual Studio along with the application itself. And while it runs perfectly fine on my own laptop, I can't get it to work on another PC.

Having done a bit research I've read about having to install SqlLocalDB.MSI. So I did just do that, but even then I constantly keep getting an error telling me that the database instance cannot be found.

At first I thought it could have something to do with the location of the database file(s), but even after a test where I put those files in the same kind of location as on my laptop (which is the C: drive) it just doesn't work.

I have honestly no idea what I'm doing wrong here. Anyone who might have an idea what I could do to get it to work correctly?

The full error I've received:

Zie het einde van dit bericht voor meer informatie over het aanroepen van JIT-foutopsporing (Just In Time) in plaats van dit dialoogvenster.

************** Tekst van uitzondering ************** System.Data.SqlClient.SqlException (0x80131904): Er is een netwerkfout of een exemplaarspecifieke fout opgetreden tijdens het maken van verbinding met SQL Server. De server is niet gevonden of is niet toegankelijk. Controleer of de exemplaarnaam correct is en of in de instellingen van SQL Server externe verbindingen zijn toegestaan. (provider: SQL Network Interfaces, error: 50 - Er is een fout in de Local Database Runtime opgetreden. The specified LocalDB instance does not exist. ) bij System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager) bij System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) bij System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) bij System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) bij System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) bij System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) bij System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) bij System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) bij System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) bij System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) bij System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry) bij System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry) bij System.Data.SqlClient.SqlConnection.Open() bij Aanwezigheidssysteem.Database.LoadEmployees() bij Aanwezigheidssysteem.Hoofdmenu.Form1_Load(Object sender, EventArgs e) bij System.Windows.Forms.Form.OnLoad(EventArgs e) bij System.Windows.Forms.Form.OnCreateControl() bij System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
bij System.Windows.Forms.Control.CreateControl() bij System.Windows.Forms.Control.WmShowWindow(Message& m) bij System.Windows.Forms.Control.WndProc(Message& m) bij System.Windows.Forms.ScrollableControl.WndProc(Message& m) bij System.Windows.Forms.Form.WmShowWindow(Message& m) bij System.Windows.Forms.Form.WndProc(Message& m) bij System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) bij System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) bij System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) ClientConnectionId:00000000-0000-0000-0000-000000000000 Error Number:-1983577849,State:0,Class:20

************** Geladen assembly's ************** mscorlib Assembly-versie: 4.0.0.0 Win32-versie: 4.7.3110.0 built by: NET472REL1LAST_C CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll ---------------------------------------- DRPAttendanceSystem Assembly-versie: 1.0.0.0 Win32-versie: 1.0.0.0 CodeBase: file:///C:/Program%20Files/DeBeerSoftware/DRP-AS/DRPAttendanceSystem.exe ---------------------------------------- System.Windows.Forms Assembly-versie: 4.0.0.0 Win32-versie: 4.7.3056.0 built by: NET472REL1 CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll ---------------------------------------- System Assembly-versie: 4.0.0.0 Win32-versie: 4.7.3056.0 built by: NET472REL1 CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll ---------------------------------------- System.Drawing Assembly-versie: 4.0.0.0 Win32-versie: 4.7.3056.0 built by: NET472REL1 CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll ---------------------------------------- System.Data Assembly-versie: 4.0.0.0 Win32-versie: 4.7.3056.0 built by: NET472REL1 CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll ---------------------------------------- System.Core Assembly-versie: 4.0.0.0 Win32-versie: 4.7.3110.0 built by: NET472REL1LAST_C CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll ---------------------------------------- System.Configuration Assembly-versie: 4.0.0.0 Win32-versie: 4.7.3056.0 built by: NET472REL1 CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll ---------------------------------------- System.Data.resources Assembly-versie: 4.0.0.0 Win32-versie: 4.7.3056.0 built by: NET472REL1 CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Data.resources/v4.0_4.0.0.0_nl_b77a5c561934e089/System.Data.resources.dll ---------------------------------------- System.Xml Assembly-versie: 4.0.0.0 Win32-versie: 4.7.3056.0 built by: NET472REL1 CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll ---------------------------------------- System.Transactions Assembly-versie: 4.0.0.0 Win32-versie: 4.7.3056.0 built by: NET472REL1 CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll ---------------------------------------- System.EnterpriseServices Assembly-versie: 4.0.0.0 Win32-versie: 4.7.3056.0 built by: NET472REL1 CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll ---------------------------------------- mscorlib.resources Assembly-versie: 4.0.0.0 Win32-versie: 4.7.3056.0 built by: NET472REL1 CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_nl_b77a5c561934e089/mscorlib.resources.dll ---------------------------------------- System.Windows.Forms.resources Assembly-versie: 4.0.0.0 Win32-versie: 4.7.3056.0 built by: NET472REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_nl_b77a5c561934e089/System.Windows.Forms.resources.dll

************** JIT-foutopsporing ************** Als u JIT-foutopsporing wilt inschakelen, moet in het configuratiebestand voor deze toepassing of computer (machine.config) de waarde jitDebugging in het gedeelte system.windows.forms zijn ingesteld. De toepassing moet ook zijn gecompileerd terwijl foutopsporing was ingeschakeld.

Bijvoorbeeld:

Wanneer JIT-foutopsporing is ingeschakeld, worden onverwerkte uitzonderingen naar het JIT-foutopsporingsprogramma gestuurd dat op de computer is geregistreerd en worden niet door dit dialoogvenster verwerkt.

sql-server
visual-studio
localdb
asked on Stack Overflow May 8, 2020 by Tom • edited May 14, 2020 by Jack J Jun - MSFT

1 Answer

0

So, I found out where it went wrong. My code was 100% alright. As it turned out however, the SqlLocalDB.MSI file was not ‘compatible’ with the DB I’ve used in my program. It was ‘derived’ from SQL Server 2014, whereas I needed the one derived from the 2016 version.

It would’ve worked nonetheless, by indeed changing the connectionstring, but for some reason I could not get that part right. So I went looking a bit further and found out that when using SQL Server 2014, the part in my connectionstring that says MSSQLLocalDB, had to be changed to V11.0 or something. However, when using SQL Server 2016, MSSQLLocalDB is correct after all.

So I sorta fixed it myself. Thanks anyway for the helpful replies everyone. :)

answered on Stack Overflow May 13, 2020 by Tom

User contributions licensed under CC BY-SA 3.0