David Dawes asked ... How to recoil the starter spring - Champion R484TR?    |    peter high asked ... How can I set time on my Neff oven?    |    Michael asked ... Mountfield empress drive belt?    |    John Barton asked ... How do i clear the TAM?    |    John asked ... How can I mend my binatone veva 1210 handset?    |    Click here to ask your question

How can I delete all rows in a data table?

I have a VB.Net question. I am having trouble deleting all rows in a data table. I am using this code........

Dim ConnStr As String = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " + System.Windows.Forms.Application.StartupPath + "\Clip Counter.mdb"
Dim DT As New DataTable()
Dim SQLStr As String = "SELECT * FROM [Clips_Data]"
Dim DA As New OleDb.OleDbDataAdapter(SQLStr, ConnStr)
Dim CommandBuilder As New OleDb.OleDbCommandBuilder(DA)
DA.Fill(DT)
DT.Rows.Clear()
DA.Update(DT)

........After the clear command all the table's rows are deleted, but it seems as though the change is not saved. What am I doing wrong?
P., February 2004
You basically need to change your SQLStr. Use the lines below instead of your example.

Dim ConnStr As String = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " + System.Windows.Forms.Application.StartupPath + "\Clip Counter.mdb"
Dim DT As New DataTable()
Dim SQLStr As String = "DELETE * FROM [Clips_Data]"
Dim DA As New OleDb.OleDbDataAdapter(SQLStr, ConnStr)
Dim CommandBuilder As New OleDb.OleDbCommandBuilder(DA)
DA.Fill(DT)
DA.Update(DT)
DA.Dispose()

Andrew Croft, February 2004
link Click here to see other fixes for Microsoft.