hello to all,
i got a problem in vb.net program, i dont how to delete multiple rows in a single table i used "truncate" command.

this is my code for deleting:

Private Sub tranc()
        Try
            Dim dbconn As OleDbConnection
            Dim dbcom As New OleDbCommand
            dbconn = New OleDbConnection(cnnstring())

            dbcom.CommandText = "TRUNCATE FROM [PartDisc_table]"
            dbcom.Connection = dbconn
            dbcom.Connection.Open()
            dbcom.ExecuteNonQuery()

            dbcom.CommandText = "TRUNCATE FROM [Distribution_table]"
            dbcom.Connection = dbconn
            dbcom.Connection.Open()
            dbcom.ExecuteNonQuery()

            dbconn.Close()
            dbcom.Dispose()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "General Error")
        End Try
    End Sub

i used access database on it.
when i run my prog. i got this error "Invalid SQL statement; expected 'delete','insert.... or 'update'.

i will appreciate for any help.

You need to use DELETE to delete records. Use proper where clause for the same.

If you want to delete all the records simply use DELETE without any WHERE clause.

I don't think TRUNCATE is supported in ACCESS.

This question has already been answered. Start a new discussion instead.