I'm using SQLite with C# and I start by creating a database file with System.IO:
System.IO.File.Create(directoryLineEdit.Text + @"\" + nameLineEdit.Text + ".db");
Now, I try to open this newly created database: (where location is the path to where the file is stored, don't mind the path parameter, that is not relevant here)
public void loadSpaceWalls(string path, string location)
{
using (SQLiteConnection conn = new SQLiteConnection("Data Source=" + location))
{
conn.Open();
using (SQLiteCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table';";
cmd.CommandType = System.Data.CommandType.Text;
SQLiteDataReader rdr = cmd.ExecuteReader();
Godot.Collections.Array wallsArray = new Godot.Collections.Array();
while (rdr.Read())
wallsArray.Add(rdr[0]);
rdr.Close();
GetNode(path).Call("updateSpaceWalls", wallsArray);
wallsArray.Dispose();
}
conn.Close();
}
}
The program crashes with System.Data.SQLite.SQLiteException (0x800007FF): unable to open database file
. Now, if I re-open my program and then access the file again (the same code, only difference is that the file has not been 'newly created' by the program, it already exists now), it works fine and doesn't crash.
This does puzzle me 🤔 Any ideas as to why this is?