C
C#2y ago
Wisch10

✅ SQLite Data Insert locks up database

I am working on a project of mine and I can get my application to create the database and its tables but when I try to insert the first set of data to populate the base data, it locks the database. public static void PopulateDBVersionTable() { using SQLiteConnection sqliteConn = CreateConnection(); sqliteConn.Open(); using DbTransaction dbTrans = sqliteConn.BeginTransaction(); try { string sql = "Insert Into tblDBVersion (dbVersion, dbBuild) values (0,100)"; using (var command = new SQLiteCommand(sql, sqliteConn)) { command.ExecuteNonQuery(); } dbTrans.Commit(); } catch (Exception ex) { dbTrans.Rollback(); MessageBox.Show(ex.Message, "Error Encountered", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (sqliteConn.State == ConnectionState.Open) { sqliteConn.Close(); } } } Any help refactoring this so that it doesn't lock up on me would be great
3 Replies
Angius
Angius2y ago
Define "lock up". If you mean only one connection can write data, then... that's how SQLite works Reading can be concurrent, but not writing
Wisch10
Wisch10OP2y ago
Each function is written like above, If I silence the other functions and only allow this one to run, I get a warning that the database is locked. If I silence this one and allow the rest to run, I don't get any errors so the error must be in the function itselft but I can't find the cause.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server