Delete Access Table from Visual Basic 2010 form

In this tutorial, we will delete table in Access Database from a visual basic form. We will delete the following table: Items:

1-Delete Access Table from Visual Basic 2010 form
(Note that you have to add the following reference to your procject: Microsoft Access 12.0 Object Library) To do that:

Go to Project – Add Reference – Click on COM tab, scroll to Microsoft Access 12.0 Object Library

2-Delete Access Table from Visual Basic 2010

  • Copy and paste
Imports Access = Microsoft.Office.Interop.Access

Imports System.Data

Imports System.Data.OleDb

Public Class Form1

Dim provider As String

Dim dataFile As String

Dim connString As String

Dim myConnection As OleDbConnection = New OleDbConnection

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source ="

dataFile = "C:\Users\Jimmy\Documents\Test Database.accdb"

connString = provider & dataFile

myConnection.ConnectionString = connString


Dim str As String = "DROP TABLE Items"

Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)



Catch ex As Exception

End Try


End Sub

End Class