[Solved] How to keep two For Each loops at the same level [closed]


you may use a for loop for one and an array incremented manually for the other like so:
Provided both these collections(or arrays) have the same number of elements:


Dim strSQLCommand As String
Dim intProductIdIndex as integer=0
For Each productQtys In productQty
strSQLCommand = "INSERT INTO Orders(SessionID, productID, qty, orderDate) " & _
"Values ('" & strSessionID & "','" & productId(intProductIdIndex) & "','" & productQtys & "','" & dateOfOrder & "');"
Dim objOleDbConnection As System.Data.OleDb.OleDbConnection
objOleDbConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & strDatabaseNameAndLocation)
objOleDbConnection.Open()
Dim objOleDbCommand As System.Data.OleDb.OleDbCommand
objOleDbCommand = New System.Data.OleDb.OleDbCommand(strSQLCommand, objOleDbConnection)
objOleDbCommand.ExecuteNonQuery()
objOleDbConnection.Close()
intProductIdIndex = intProductIdIndex + 1
Next

1

solved How to keep two For Each loops at the same level [closed]