Forums - C# Corner

Forum guidelines
Griffin Kamotho

Griffin Kamotho

  • 1.5k
  • 3
  • 128

Unable to update records in a table

Sep 21 2017 3:17 AM
Am unable to update records in a table here is the code am using. am able to read the table data but when i update it is not updating. Here is the code.
 
string Conx = @"Data Source=" +
(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)) +
"\\ReaderDB.sdf;Persist Security info=False";
conn =new SqlCeConnection(Conx);
conn.Open();
SqlCeTransaction Trans = conn.BeginTransaction();
try
{
istr = "Update TblLogger set CRead=" + CRead + ",Consumption=" + Consumption + ",Status='" + cboStatus.Text + "' where WSNO='" + cellValue + "'";
comm.Connection = conn;
comm = new SqlCeCommand(istr, conn, Trans);
comm.ExecuteNonQuery();
Trans.Commit();
txtReads.Text = "";
}
catch (Exception)
{
MessageBox.Show("Data not posted").ToString();
}
 

Answers (1)