Kostakis45
Active member
- Joined
- Apr 3, 2022
- Messages
- 37
- Programming Experience
- Beginner
I'm trying to delete a record from database.
My command line seems fine and I'm guessing that the problem lies in the reference I'm doing to get the value from textbox.But I can't figure out why it's not showing any errors,instead the program freezes.
Any idea or suggestion?
Delete_Redord.cs:
public void Delete_Info_From_DB()
{
Plasteka pa = new Plasteka();//Main Form
var con = new SQLiteConnection(connection);
con.Open();
var cmd = new SQLiteCommand(con);
try
{
cmd.CommandText = "DELETE FROM Description WHERE Mould_Code = '"+pa.Search_Box.Text+"'";//Am I missing something here? BTW Mould_Code is PK integer.
cmd.ExecuteNonQuery();
}
catch
{
if ((cmd.CommandText = "SELECT * FROM Description WHERE Mould_Code = '" + pa.Search_Box.Text + "'") == null)
{
MessageBox.Show("Επιτυχής διαγραφή.");
pa.mould_code_input.Text = null;
pa.machine_number_input.Text = null;
pa.machine_type_input.Text = null;
pa.supplier_input.Text = null;
pa.colour_input.Text = null;
pa.comboBox1.Text = null;
pa.comboBox2.Text = null;
pa.comboBox3.Text = null;
pa.numericUpDown1.Text = null;
pa.numericUpDown2.Text = null;
pa.numericUpDown3.Text = null;
pa.dateTimePicker1.Text = null;
pa.item_name_input.Text = null;
pa.pictureBox1.Image = null;
pa.pictureBox2.Image = null;
}
else
{
MessageBox.Show("Αποτυχία διαγραφής.");
}
}
con.Close();
}
Any idea or suggestion?