C
C#13mo 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
Angius13mo 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
Wisch1013mo 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
Accord13mo 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
More Posts
❔ Serilog duplicate log with global exception handlinghey i am building an asp.net core web api and i implemented global exception handling like this: ``✅ What is the function of the Dictionary here?public class Solution { Dictionary<int,int>cached=new Dictionary<int,int>(); public int Cli❔ JWT Refresh tokensI've got a RefreshToken endpoint on my UserController class. I'm currently able to regenerate these ❔ System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Runtime, Version=6.0.0.0Hey all I am designing a win forms application and when trying to test a build I am greeted with the❔ streaming an IAsyncEnumerable<string> from complex typehey. i have a minimal api that looks like this: ```cs public static async IAsyncEnumerable<string> A❔ Assign result from await to a variableIs there a difference between those two calls? `var awaitable = await GetObject(); otherObject.IntP❔ ✅ Prints System.Func`1[System.Int32] instead of actual int.I'm trying to return a private field member variable and instead of giving me the actual integer val❔ Exception trying to run code from a .NET Framework 4.5.2 on .NET 6 projectHi, I have a new project using .NET 6, but I need to call a method in a project using .NET Framewo✅ Hosting web app with SQL Server for free/minimal cost?Hello there, I was wondering if anyone knew any cloud/hosting providers that allow hosting an ASP.N❔ WinUI3: Restoring Window Size on relaunchIn UWP and WinUI2, it would automatically relaunch to the last width/height of the application, but