I have to clear out all old records from multiple MS Access tables each time my program begins (clearing out the data from the last run).
Each table can have as many as 15000 rows and the method I am using now is quite slow. Is there a better way to clear out the table than deleting one row at a time as I am doing in the code below?
Thanks,
Charlie
Here's my code:
Sub ClearMeasurementTable()
Dim conn As New OleDbConnection(constr)
Dim qry As String = "SELECT * FROM Measurement"
Dim daTestTbl As New OleDbDataAdapter(qry, conn)
Dim cbTestTbl As New OleDbCommandBuilder(daTestTbl)
Dim dtTestTbl As New DataTable()
Try
daTestTbl.Fill(dtTestTbl)
For Each dr As DataRow In dtTestTbl.Rows
dr.Delete()
Next
daTestTbl.Update(dtTestTbl)
dtTestTbl.Dispose()
daTestTbl.Dispose()
Catch ex As Exception
MsgBox(ex.Message, vbOKOnly, "Clear Measurement Table!")
End Try
End Sub
That's another topic - and one I am interested in. I was going to search to see if there was a command for compacting the database from VB.Net.
Any info?