I am trying to insert multiple record into my Access Database. Currently I can insert a single transaction record with the code below
Try
sql = "INSERT INTO tblINV_SalesRecord " &_
"(transID, itemcode, itemname, itemunits ) " &_
"VALUES ('TGR011111','Cheese','INV0234','5')"
Using con1 As New OleDbConnection(dbProvider & dbSource)
Dim command As New OleDbCommand(Sql, con1)
con1.Open()
command.ExecuteScalar()
MsgBox("Record Inserted")
End Using
Catch ex As Exception
MsgBox("An Error Occured")
MessageBox.Show(ex.Message & " - " & ex.Source)
End Try
Now what I am trying to do is to insert multiple items purchased by customer in a single SQL statement. My code is shown below.
Try
sql = "INSERT INTO tblINV_SalesRecord " &_
"(transID, itemcode, itemname, itemunits ) " &_
"VALUES ('TGR011111','Cheese','INV0234','5')," &_
"('TGR011111','Cake','INV0114','2')," &_
"('TGR011111','Burger','INV0217','3')" &_
Using con1 As New OleDbConnection(dbProvider & dbSource)
Dim command As New OleDbCommand(Sql, con1)
con1.Open()
command.ExecuteScalar()
MsgBox("Record Inserted")
End Using
Catch ex As Exception
MsgBox("An Error Occured")
MessageBox.Show(ex.Message & " - " & ex.Source)
End Try
But it returns Error. Please how do I get this resolved?