private void button3_Click(object sender, EventArgs e) { if (counter != "0") { DialogResult dg = MessageBox.Show("Are you sure?", "Alert!", MessageBoxButtons.YesNo); if (dg == DialogResult.Yes) { string insertQuery = "DELETE FROM items WHERE id =" + dgv.Rows[dgv.SelectedRows[0].Index].Cells[0].Value.ToString(); executeMyQuery(insertQuery); refresh("select items.id, items.name, category.description,items.status from items left join category on category.id = items.categoryID"); setCount("Select COUNT(*) as test from items "); var a = new AddEquip(); a.setCount("SELECT id+1 AS next_id FROM items ORDER BY id DESC LIMIT 1"); } } else { MessageBox.Show("Table is empty.", "Error. ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }