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 PPosted Sep 19, 2017, 2:43 AM
Jyoti JodhaPosted Sep 19, 2017, 2:19 AM
Rafnas T PPosted Sep 19, 2017, 2:01 AM
Rafnas T PPosted Sep 19, 2017, 1:58 AM
Kailash PolaiPosted Sep 18, 2017, 8:33 AM
Amit GuptaPosted Sep 16, 2017, 6:53 AM
Jyoti JodhaPosted Sep 16, 2017, 6:50 AM
Amit GuptaPosted Sep 16, 2017, 6:36 AM
Jyoti JodhaPosted Sep 16, 2017, 6:31 AM
Amit GuptaPosted Sep 16, 2017, 6:06 AM