I'm trying to get a C# program to interface with a MS access database and so far everything has worked perfectly. But now I have stumbled up a problem while trying to update an existing record.
The code I have is
Where first set of variables is where the updated values are coming from.Code:string Lname = Client_LName_Field.Text; string Fname = Client_FName_Field.Text; string Address = Client_StAddress_Field.Text; string Suburb = Client_Suburb_Field.Text; string City = Client_City_Field.Text; string Phone = Client_Phone_Field.Text; //DataRow updateRow = DB.dsClient.Tables["T_Client"].Rows[foundId]; DataRow updateRow = DB.dtClient.Rows[foundId]; updateRow["LastName"] = Lname; updateRow["FirstName"] = Fname; updateRow["StreetAddress"] = Address; updateRow["Suburb"] = Suburb; updateRow["City"] = City; updateRow["PhoneNumber"] = Phone; DB.daClient.Update(DB.dsClient, "T_Client");
The commented out line was a way I got the row to update but found the line below it was much more simpler to use.
the next block of code is for the actual update where the values are placed in the old row.
and the last line is the the update of the database.
DB is the class where all the database variables are stored.
daClient is the data adapter for the Client table in the database
dsClient is the data set for the client table
dtClient is the data table for the client table in the database
foundID id the position number of the row to edit
T_Client is the name of the client table in the database
What the code does is it updates the loaded database data that is running in the memory while the program is running but does not update the actual stored database in the file on the HDD so the changes to the database only exist while the program is running.
Any ideas as to what the problem is or how to fix it would be appreciated.
Thanks


Reply With Quote
