Hi,
I am trying to edit/update fields in a single Access table using C# Express. I have tried the following two sets of code. Both compile and run with no reported errors. Neither actually writes any changes to the database table.
Can anyone tell me what I'm doing wrong?
Thanks
Ian
............................................................................................
Attempt #1
............................................................................................
private void EditJob(Int32 iUID) {
string sqlCmd = "UPDATE JobList SET ClientRef = '" + tbClientRef.Text + "' WHERE UID = '" + iUID.ToString() + "'";
this.jobListTableAdapter.Adapter.UpdateCommand.CommandText = sqlCmd;
iResult = this.jobListTableAdapter.Update(this.dSJobList.JobList);
this.dSJobList.AcceptChanges();
....
}
............................................................................................
Attempt #2
............................................................................................
private void EditJob(Int32 iUID) {
this.jobListTableAdapter.Fill(this.dSJobList.JobList);
DataRow[] drow = dSJobList.JobList.Select("UID = '" + iUID.ToString() + "'");
foreach (DataRow dr in drow) // Should only be one row
{
dr.BeginEdit();
dr["ClientRef"] = tbClientRef.Text;
dr.EndEdit();
dr.AcceptChanges();
this.jobListTableAdapter.Fill(this.dSJobList.JobList);
}
Loading
Vijaya KadiyalaPosted Feb 6, 2009, 1:06 PM
string sqlCmd = "UPDATE JobList SET ClientRef = '" + tbClientRef.Text + "' WHERE UID = '" + iUID.ToString() + "'";
I feel the issue is with the above query. may be the WHERE condition is not satisying thats the reason it is not updating any record in database. So do one thing, what ever the values that you are passing to this queryusing textbox or what ever just directly replace them in the query and run that query on MS Access and see what you are getting.
Thanks
Vijaya Kadiyala
http
://dotnetvj.blogspot.com