Fouzia Qureshi

Fouzia Qureshi

  • NA
  • 36
  • 2.2k

SqlCommandBuilder not updating record in database

Jan 25 2021 8:46 PM
private void btn_update_Click(object sender, EventArgs e){
try
{
conStr = @"--------------";
con = new SqlConnection(conStr);
con.Open();
string query = "Select * from tblProduct";
cmd = new SqlCommand(query, con);
sda = new SqlDataAdapter(cmd);
SqlCommandBuilder scb = new SqlCommandBuilder(sda);
sda.Update(tbl);
tbl.AcceptChanges();
con.Close();
MessageBox.Show("Data Updated :) ");
}
catch (Exception ex)
{
MessageBox.Show("error" + ex.Message);
}
}

Answers (3)