Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

Delete all the records in a table.

How do I delete all the records form an ACCESS table where I have a OleDbDataAdapter  and  a Dataset ?
0
Mylor
Asked:
Mylor
1 Solution
 
MylorAuthor Commented:
and ????
0
 
grayeCommented:
Well, that depends on what you mean by "delete"....

If you want to delete the rows of data in your disconnected DataTable (and leave the source database alone), then a simple solution would be:

        DataTable.clear()

However, if you want to delete all records in the source database, then a simple SQL command would be most efficient

        OleDbCommand.CommandText = "Delete * from Table1"
        OleDbCommand.ExecuteScalar()

If for some reason you need to do this with just the DataAdapter, you'd do the following

        for each dr in DataSet.Tables("Table1").Rows
               dr.delete
        next
        DataAdapter.Update(DataSet)
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now