bigboi214
bigboi214

Reputation: 21

updating a database using a table adapter and data table

I am currently working on a VB program connected to an Access database. I have fill a data table using a query and data adapter. At a later stage in the program, i want to go through and make permanent changes to the database using the adapter and table. I tried this:

For Each row As DataRow In db.DBDT.Rows

            row("fldsentda") = "Y"
            row("flddasenddate") = Date.Today
        Next row


        'db.DBDT.AcceptChanges()
        db.DBDA.Update(db.DBDT)

*db is a class file, dbda is the data adapter, and dbdt is the data table

but i realized these changed are only effected the data table and not the actual database. How can I get it to where it will effect only the database rows that are inside of the data table filled using the query?

Update: I'm thinking my update function isn't written. I don't know if this should be a separate question or not, but how do I write the update function to only change fields in the database that has been changed on the data table??

Upvotes: 0

Views: 882

Answers (1)

ChD Computers
ChD Computers

Reputation: 3137

Do not call

db.DBDT.AcceptChanges()

before

db.DBDA.Update(db.DBDT)

Doing so marks everything in the datatable as not changed. See here especially in remarks section.

Just call the update method and the acceptchanges should be called automatically for you.

Upvotes: 1

Related Questions