Results 1 to 2 of 2

Thread: Simple ADO.NET questions - Part II

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Simple ADO.NET questions - Part II

    1. What does the Update method of the data adapter actually do? Does it make the changes in the database, or something else?

    2. What is .AcceptChanges()?

    3. My reason for asking question #1 is this:

    When updating in the simple DB application I'm making, I need only to set the command object, its parameters, and UPDATE the data adapter.

    When deleting, though, I have to actually perform a .ExecuteNonQuery in addition to the .Update() method.

    Why this difference?

  2. #2
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    The update method applies all changes made to the local dataset when you call this. . . Provided that you have associated the appropriate commands with your data adapter.

    It is necessary to set the SelectCommand, InsertCommand, UpdateCommand, and DeleteCommand with the appropriate command objects. Once you have done this, all changes will be submitted back to the database when you call the DataAdapter.Update method.

    AcceptChanges applies only to the local dataset, this can be a dangerous method as it tells the DataAdapter to commit all changes to the (Local) data set only, not back to the data source. So if you were to call AcceptChanges and follow it up with Update, you would find that your changes would not be written back to the data source.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width