I am creating an application with MS Access as back-end. I am running delete query but it is not working Code:
conchek.ConnectionString = ConfigurationManager.ConnectionStrings["KedarnathDB"].ConnectionString;
conchek.Open();
OleDbCommand cmdc = new OleDbCommand("select * from ReceiptsTrns Where ID=@CallerName", conchek);
cmdc.Parameters.Add("@CallerName", OleDbType.Numeric).Value = txtRcptNo.Text.Trim();
OleDbDataReader rd = cmdc.ExecuteReader();
if (rd.HasRows)
{
conchek.Close();
con1.ConnectionString = ConfigurationManager.ConnectionStrings["KedarnathDB"].ConnectionString;
con1.Open();
OleDbCommand cmd = new OleDbCommand("DELETE from ReceiptsTrns Where ID=@RCName", con1);
cmd.Parameters.Add("@RCName", OleDbType.Numeric).Value = txtRcptNo.Text.Trim();
con1.Close();
MessageBox.Show("Receipt deleted successfully");
}
else
{
conchek.Close();
MessageBox.Show("No receipt found with this number");
}
the code is running successfully but it is not reflecting the change when I see my MS Access database.