Hi all, I'm wondering if there is an issue with calling SQLite in an event handler ? I have a
The weird thing is that the debugger never hits a breakpoint which I have set in the event handler on a line before the SQLite. So I don't know where and why it locks up. Only when I actually comment out the SQLite code, the trigger starts working and becomes debuggable again. I am at a loss to understand what voodoo is happening here
Note, I'm using
Note 2, the same code works fine when called from the form's
My event handler :
TextChanged
handler that attempts to check for a row in the database. When the event handler is fired, my program freezes, as well as Visual Studio and, indeed, the entire Windows Explorer ! The only thing saving me from having to log out or reboot is that I can still do Ctrl-Alt-Del
, run the task manager and kill my program.The weird thing is that the debugger never hits a breakpoint which I have set in the event handler on a line before the SQLite. So I don't know where and why it locks up. Only when I actually comment out the SQLite code, the trigger starts working and becomes debuggable again. I am at a loss to understand what voodoo is happening here
Note, I'm using
System.Data.SQLite
because I had some problem (which I don't remember) with Microsoft.Data.SQLite
.Note 2, the same code works fine when called from the form's
Load
event handler.My event handler :
TextChanged event handler:
private void tbDate_TextChanged(object sender, EventArgs e)
{
if ( tbDate.Text.Length == 0 )
return;
long count = -1; /* Breakpoint on this line is never hit ! */
using (var conn = new SQLiteConnection($"Data Source={DATABASE}") )
{
conn.Open();
var cmd = conn.CreateCommand();
cmd.CommandText = $"select count(*) from meterstanden where date = '{tbDate.Text}'";
try
{
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
foreach (var field in reader.GetValues())
{
count = (long)reader[(string)field];
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Select count(*) failed");
}
conn.Close();
}
MessageBox.Show("" + count, "Select count(*) result");
}
Last edited: