我有以下代码循环遍历我的数据表(dtItem)并将每一行插入数据库。但是,我只能插入数据表的最后一行。我如何插入所有行?这是我的代码。
将 dtRow 调暗为 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