The program executes one cmd.commandtext at a time. Both of my tables are using the same primary keys which is ID.
How do I execute both cmd.commandtext at the same time?
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim cnnOLEDB As New OleDbConnection
Dim cmdInsert As New OleDbCommand
Dim cmdOLEDB As New OleDbCommand
Dim cmdUpdate As New OleDbCommand
Dim connection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Harry\Documents\Database1.accdb;"
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
cnnOLEDB.ConnectionString = connection
cnnOLEDB.Open()
End Sub
Private Sub btnReal_Click(sender As Object, e As EventArgs) Handles btnReal.Click
If txtName.Text <> "" And txtId.Text <> "" And txtReceipt.Text <> "" Then
cmdUpdate.CommandText = "UPDATE customer Set Stu_Name = '" & txtName.Text & " ' " & "WHERE ID = " & txtId.Text & " ; "
cmdUpdate.CommandText = "UPDATE admin Set receipt = '" & txtReceipt.Text & " ' " & "WHERE ID = " & txtId.Text & " ; "
cmdUpdate.CommandType = CommandType.Text
cmdUpdate.Connection = cnnOLEDB
cmdUpdate.ExecuteNonQuery()
cmdUpdate.Dispose()
MsgBox(txtName.Text + "Record Updated!")
End If
End Sub