Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim conStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\DBTest.accdb;Persist Security Info=False;"
Dim con As New OleDbConnection
Dim cmd As New OleDbCommand
Dim sqlStr1, sqlStr2 As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con = New OleDbConnection(conStr)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
sqlStr1 = "INSERT INTO TB1 (Tb1_Name) VALUES ('Test1')"
sqlStr2 = "INSERT INTO TB2 (Tb2_Name) VALUES ('Test2')"
con.Open()
'insert table1
cmd = New OleDbCommand(sqlStr1, con)
cmd.ExecuteNonQuery()
'insert table2
cmd = New OleDbCommand(sqlStr2, con)
cmd.ExecuteNonQuery()
con.Close()
End Sub
End Class