Problem connecting to SQLite database

  • Thread starter Thread starter Joneboy
  • Start date Start date
J

Joneboy

Guest
HI I have a probelm trying to open a connection to a sqlite database from Visual Basic.net - I am using Visual Studio Community 2019

I have added a reference to Microsoft.Data.SQLite in my vb project via Nuget

I have these 2 lines of code

Dim MyDataConnection = New SqliteConnection("Data Source=" & PathToLocalData)
MyDataConnection.Open()

The .Open() generates a nullreferenceexception

PathToLOcalData is a variable containing the full path to the sqlite database and the file exists. I have tried creating the database as both a sqlite3 and a system.data.sqlite

Error:
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=SQLitePCLRaw.core
StackTrace:
at SQLitePCL.raw.sqlite3_open_v2(String filename, sqlite3& db, Int32 flags, String vfs)
at Microsoft.Data.Sqlite.SqliteConnection.Open()
at AspectData.Data.GetDatabaseConnection() in D:\Projects\AspectOH\AspectOH\AspectData\Data.vb:line 60


Can anyone offer any assistance? I've searched around the coding forum examples and can't see I'm doing anything wrong.

Continue reading...
 
Back
Top