SQLite connection issue

Godot Version

4.2

Question

I am trying to use SQLite database using System.Data.SQLite, but I can’t create one. When I try to do so with:

string connectionString = $"Data Source=database.db;Version=3;";
var connection = new SQLiteConnection(connectionString);

I get exception string System.IO.Path.Combine(string, string): System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
All I can find on this matter is this StackOverflow topic: c# - "Value cannot be null. (Parameter 'path1')" on connectionString - Stack Overflow
It suggests to set some parameters like IncludeNativeLibrariesForSelfExtract and PublishSingleFile in the .csproj file, but it does not work for me, getting the same exception. Anyone has an idea in which direction should I move?

I won’t be able to help directly, but I recommend trying your question in the ChickenSoft Discord: Chickensoft ChickenSoft is the home to some really helpful Godot C# developers.

1 Like

Some friendly guy on the Godot discord(@xill47) suggested to use Microsoft.Data.Sqlite instead of System.Data.SQLite. Which worked :star_struck:.

Also, little bit later I decided to have my db encrypted with password, for that I switched to the sqlite-net-sqlcipher (GitHub - praeclarum/sqlite-net: Simple, powerful, cross-platform SQLite client and ORM for .NET) which works nicely too.
I create an encrypted db like so:

SQLiteConnectionString connectionStr = new(DBPath, true, password);
DB = new SQLiteConnection(connectionStr);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.