I have the following code to loop through my datatable (dtItem) and insert each row into the database. However, i can only insert the last row of the datatable. How do i insert all rows? Here is my code.
Dim dtRow As DataRow
For Each dtRow In dtItem.Rows
dtRow.ToString.Split("|")
Dim xBinCode As String = dtRow(0)
Dim xLocationCode As String = dtRow(7)
Dim xItemNo As String = dtRow(1)
Dim xQuantity As String = dtRow(2)
Dim xCountNo As String = dtRow(8)
cmd.CommandText = "INSERT INTO tblItems (BinCode, LocationCode, ItemNo, Quantity, CountNo) values('" & xBinCode & "','" & xLocationCode & "','" & xItemNo & "','" & xQuantity & "','" & xCountNo & "')"
Next