[C#, MSAccess] Update DB using DataAdapter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kermit
    New Member
    • Aug 2007
    • 16

    [C#, MSAccess] Update DB using DataAdapter

    Hi,
    I have the following problem. I load 3 tables to a dataset aaco, and then perform some operations on two tables (insert 1 row in the first table, update one field in the second), and try to call dataAdapter.Upd ate method, and I get an exception.

    Tables:
    - audits (id, object id, ...)
    - controlledObjet cs (id, ...)

    [c# code]
    OleDbCommandBui lder myCommandBuilde r = new OleDbCommandBui lder(aacoDataAd apter);
    aacoDataAdapter .Update(ds, "audits");
    aacoDataAdapter .Update(ds, "controlledObje cts"); <=* exception thrown here
    [/code]

    aacoDataAdapter - OleDbDataAdapte r
    ds - DataSet

    * Exception: "Missing the DataColumn 'objectId' in the DataTable 'controlledObje cts' for the SourceColumn 'objectId'."

    But there cannot be such a column, because it is in the audits table, not in the controlledObjec ts one :|
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    seems the dataAdapter is hooked on to the audits table,
    try to create a different adapter for the other table

    Comment

    • Kermit
      New Member
      • Aug 2007
      • 16

      #3
      Originally posted by Shashi Sadasivan
      seems the dataAdapter is hooked on to the audits table,
      try to create a different adapter for the other table
      It worked, thanks. I haven't thought about that. But is there another way to do that using only one data adapter?

      Comment

      • Kermit
        New Member
        • Aug 2007
        • 16

        #4
        Another question on the topic:
        How can I check for any difference between data stored in dataset, and in the database.

        For example: I have dataset that has data retrieved from the database.
        I add a row, and then remove it. The data is still the same. Now, on closing the application I'd like to inform the user, that the dataset and the database contain different information, but only when they really do.

        Does C# have any tools for checking such stuff?

        Thanks in advance.

        Comment

        Working...