Mike asked ... Bosch WTA74200GB Vented Dryer?    |    Stuart G asked ... C3 Front Wiper control problem?    |    Clare S asked ... Repair Electriq dehumidifier?    |    Bob asked ... Charger fault?    |    Terry nelson asked ... How to remove the flexible shaft from a curved shaft ryobi t?    |    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.