✅ 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.
Any help refactoring this so that it doesn't lock up on me would be great
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
