Dataadapter DeleteCommand - OLEDB Data Source
OleDbDataAdapter is a part of the ADO.NET Data Provider. The OleDbDataAdapter works with the DataSet to provide a disconnected data retrieval mechanism. The InsertCommand, UpdateCommand, and DeleteCommand properties of the OleDbDataAdapter are Command objects that manage updates to the specified data source according to modifications.
The following Source Code shows how to perform delete data from a database using DeleteCommand property of OleDbDataAdapter.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connetionString As String
Dim connection As OleDbConnection
Dim oledbAdapter As New OleDbDataAdapter
Dim sql As String
connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your mdb filename;"
connection = New OleDbConnection(connetionString)
sql = "delete from Users where UserID = 'user1'"
oledbAdapter.DeleteCommand = connection.CreateCommand
oledbAdapter.DeleteCommand.CommandText = sql
MsgBox("Row(s) Deleted !! ")
Catch ex As Exception