[OleDB] Daten in MS Access löschen (DELETE)

Dim DB_OleDBCommandDelete As New System.Data.OleDb.OleDbCommand
Dim sSQL As String

Try
    ' steht die Datenbankankbindung?
    If DB_OleDBConnection.State = System.Data.ConnectionState.Open Then
        DB_OleDBCommandDelete.Connection = DB_OleDBConnection
        sSQL = "DELETE FROM Users WHERE ID=1"

        DB_OleDBCommandDelete.CommandText = sSQL
        DB_OleDBCommandDelete.ExecuteNonQuery()
    End If

    DB_OleDBCommandDelete.Dispose()
    DB_OleDBCommandDelete = Nothing
Catch ex As Exception
    MessageBox.Show("Fehler: " & ControlChars.CrLf & ex.ToString())
End Try

Schreibe einen Kommentar