EDIT! Here's the video of the error https://www.youtube.com/watch?v=_mJ3o3ykQrw
Made a method called AddAttendance in my database handler class. I can access it from other class since it's static. Here's the code:
public static void AddAttendance(string ID, string DateTime, string Action, string Session)
{
SQLiteConnection sqlite_conn = new SQLiteConnection("Data Source = " + database + "; Version = 3; New = True; Compress = True;");
try
{
sqlite_conn.Open();
SQLiteCommand sqlite_cmd = sqlite_conn.CreateCommand();
sqlite_cmd.CommandText = "INSERT INTO AttendanceLog (UserID, DateTime, Action, Session) VALUES (" +
"'" + ID + "', '" + DateTime + "', '" + Action + "', '" + Session + "');";
sqlite_cmd.ExecuteNonQuery();
sqlite_conn.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
sqlite_conn.Close();
}
This code is only being accessed by this Dialog Form I made bound to a button:
private void buttonAccept_Click(object sender, EventArgs e)
{
if (textBoxID.Text.Length == 0 || textBoxTimeDate.Text.Length == 0)
{
MessageBox.Show("ID or Time and Date cannot be empty!", "Missing field", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (buttonAccept.Text.Equals("Accept"))
{
buttonAccept.Text = "Confirm!";
return;
}
DatabaseHandles.AddAttendance(textBoxID.Text, textBoxTimeDate.Text, comboBoxAction.Text, comboBoxSession.Text);
MessageBox.Show("Record added!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
}
If im accessing it from my Form Kiosk mode, it's working just fine, but if I'm accessing it from anywhere else, it reports Database is locked.
What's weird is, when i accessed it first to my Kiosk mode beforehand then to other place, it works just fine.
I dont know what am i missing. Here the same code i use on calling the form:
AttendanceInsert ai = new AttendanceInsert();
ai.ShowDialog();