Recent: Fix food processor motor?

Mend Microsoft Application Development

Mend Software, Application Development
Find out how to mend it for free.

Ask Question
Mend Software, Application Development
Free repair help for Microsoft application development

Mend > Application Development

Mend Microsoft

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
Mend Software, Application Development
Free repair help for Microsoft application development

How to mend ...

Find out how to mend just about anything howtomendit.com for free repair help, information and advice.
Mend Software, Application Development
Free repair help for Microsoft application development