How to before delete records check in two tables same field name c#
i want to before delete check in two tables "MainBillForm" and "suppliers_Form"
if (Product_ID != 0)
{
cmd = new SqlCommand("IF NOT EXISTS(SELECT Product_Name FROM MainBillForm,suppliers_Form WHERE Product_Name = '" + Product_ID + "')delete Product where Product_ID=@id", con);
con.Open();
cmd.Parameters.AddWithValue("@id", Product_ID);
btn_Insert.Text = "Save";
int k = cmd.ExecuteNonQuery();
con.Close();
if (k > 0)
{
MessageBox.Show("Record Deleted Successfully!");
}
else
{
MessageBox.Show("Product is Already used in Bill So you don't Deleted this Product !");
}


Rafnas T PRank #280 · 8.8K reputationPosted Sep 18, 2017, 10:43 PM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Sep 16, 2017, 2:06 AM EDT
Jyoti JodhaRank #1,408 · 1.2K reputationPosted Sep 16, 2017, 2:31 AM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Sep 16, 2017, 2:36 AM EDT
Jyoti JodhaRank #1,408 · 1.2K reputationPosted Sep 16, 2017, 2:50 AM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Sep 16, 2017, 2:53 AM EDT
Kailash Polai195 reputationPosted Sep 18, 2017, 4:33 AM EDT
Rafnas T PRank #280 · 8.8K reputationPosted Sep 18, 2017, 9:58 PM EDT
Rafnas T PRank #280 · 8.8K reputationPosted Sep 18, 2017, 10:01 PM EDT
Jyoti JodhaRank #1,408 · 1.2K reputationPosted Sep 18, 2017, 10:19 PM EDT