EFileTahi-A Posted December 17, 2004 Posted December 17, 2004 Hi again, I have managed to "ADD" a record and update the changes to the Access database, but I have not figured yet how can I "CHANGE" a record and save the changes to do database. At What is worng with this code? tempDT.Rows[2].BeginEdit(); tempDT.Rows[2]["descri"] = "BLABLA"; tempDT.Rows[2].EndEdit(); tempDT.Rows[2].AcceptChanges(); oOleDbDA.Update(tempDT); The code executes with no prob, though the database does not assume the changes. Or, maybe (most certain) the changes are not sent to the database at all! Quote
Administrators PlausiblyDamp Posted December 17, 2004 Administrators Posted December 17, 2004 Hi again, I have managed to "ADD" a record and update the changes to the Access database, but I have not figured yet how can I "CHANGE" a record and save the changes to do database. At What is worng with this code? tempDT.Rows[2].BeginEdit(); tempDT.Rows[2]["descri"] = "BLABLA"; tempDT.Rows[2].EndEdit(); tempDT.Rows[2].AcceptChanges(); oOleDbDA.Update(tempDT); The code executes with no prob, though the database does not assume the changes. Or, maybe (most certain) the changes are not sent to the database at all! Calling accept changes flags all modified records in the dataset has being saved. Move the call to Acceptchanges to after the .Update and things should work fine. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
EFileTahi-A Posted December 17, 2004 Author Posted December 17, 2004 Hi, tks for the reply, If I put the "acceptChanges" after the update it gives me an error... :( Quote
Administrators PlausiblyDamp Posted December 18, 2004 Administrators Posted December 18, 2004 and the error is? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
EFileTahi-A Posted December 20, 2004 Author Posted December 20, 2004 "An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll Additional information: Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information." Quote
Administrators PlausiblyDamp Posted December 20, 2004 Administrators Posted December 20, 2004 How are you creating the data adapter? Are you providing your own update statement or letting VS generate one for your? If the later then you need to make sure that one of the columns you are retreiving is the table's primary key. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
EFileTahi-A Posted December 21, 2004 Author Posted December 21, 2004 (edited) Hi, tks for replay, am not sure if I understand what did u said in ur last post. But, I do know that am creating an DataAdapter all right and am letting VStudio to generate de code for me (if I understood correctly what u have said). Could u point me to an "Update" example? Because I believe that a small example worths more that one thousand words. Anyway, am still trying to get one (example) in Web... Edited December 21, 2004 by EFileTahi-A Quote
Administrators PlausiblyDamp Posted December 22, 2004 Administrators Posted December 22, 2004 How is the tabl configured in Access? Does it have a primary key declared? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
EFileTahi-A Posted December 23, 2004 Author Posted December 23, 2004 Ah, no, I did not had an a primary key defined, and, after I define one, the "AcceptChanges" after the "DataAdapter.Update" MADE IT WORK! Ok, for the help and patience with me :) - THREAD RESOLVED - Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.