try
{
OleDbConnection con = new OleDbConnection(ConnectionString);
con.Open();
string s1 = dtp_date.Value.ToShortDateString();
OleDbCommand cmd = new OleDbCommand("update dbo_Diesel_Master set Petrol_pump_name='" + txt_Petrl_pump_name.Text + "',Vehicle_No='" + cmb_VehicleNo.Text + "',Fuel='" + txt_Fuel.Text + "',Rate='" + txt_rate.Text + "',Date='" + s1 + "',Challan_No='" + txt_challan_no.Text + "',Amount='" + txt_amt.Text + "' where Petrol_pump_name='" + DGV_Diesel.SelectedRows[0].Cells[0].Value + "'", con);
cmd.ExecuteNonQuery();
cmd = new OleDbCommand("select * from dbo_Diesel_Master", con);
dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(dr);
DGV_Diesel.DataSource = dt;
MessageBox.Show("updated successfully.....");
con.Close();
}
catch (Exception ex)
{
MessageBox.Show("please select a record for delete..");
}