MS Access データベースのアイテムをリストビューに表示しようとしていますが、理由がわからない奇妙な理由で、リストビューにはすべてのレコードが表示されますが、いくつかのレコードが空白のままになります
アイテムをロードするために使用するサブは次のとおりです。
Public Sub LoadItems()
If tcOverzicht.SelectedIndex = 0 Then
Dim strQuery As String = "SELECT tblItems.itemID, tblItems.Referentie, tblType.Type, tblItems.Stock, tblItems.Barcode, tblItems.Omschrijving, tblItems.Merk, tblItems.Opmerking " & _
"FROM tblItems INNER JOIN tblType ON tblItems.typeID = tblType.typeID WHERE tblItems.typeID=" & intType & ";"
Dim da As New OleDbDataAdapter
Dim cmd As New OleDbCommand(strQuery, cnConnectie)
Dim TABLE As New DataTable
With da
.SelectCommand = cmd
.Fill(TABLE)
End With
'Listview leeg maken
lvItems.Items.Clear()
'Listview vullen met de gegevens uit de DB
For i As Integer = 0 To TABLE.Rows.Count - 1
With lvItems
.Items.Add(TABLE.Rows(i)("itemID"))
With .Items(.Items.Count - 1).SubItems
.Add(TABLE.Rows(i)("Referentie"))
.Add(TABLE.Rows(i)("Type"))
.Add(TABLE.Rows(i)("Stock"))
.Add(TABLE.Rows(i)("Barcode"))
.Add(TABLE.Rows(i)("Omschrijving"))
.Add(TABLE.Rows(i)("Merk"))
.Add(TABLE.Rows(i)("Opmerking"))
End With
End With
Next
End If
If tcItems.SelectedIndex = 0 Then
Dim strQuery As String = "SELECT tblItems.itemID, tblItems.Referentie, tblType.Type, tblItems.Stock, tblLeveranciers.Leverancier, tblItems.Barcode, tblItems.MinStuks,tblItems.Omschrijving, tblItems.Merk, tblItems.Opmerking " & _
"FROM (tblItems INNER JOIN tblLeveranciers ON tblItems.leveranciersID = tblLeveranciers.leveranciersID) INNER JOIN tblType ON tblItems.typeID = tblType.typeID;"
Dim da As New OleDbDataAdapter
Dim cmd As New OleDbCommand(strQuery, cnConnectie)
Dim TABLE As New DataTable
With da
.SelectCommand = cmd
.Fill(TABLE)
End With
'Listview leeg maken
lvArtikel.Items.Clear()
'Listview vullen met de gegevens uit de DB
For i As Integer = 0 To TABLE.Rows.Count - 1
With lvArtikel
.Items.Add(TABLE.Rows(i)("itemID"))
With .Items(.Items.Count - 1).SubItems
.Add(TABLE.Rows(i)("Referentie"))
.Add(TABLE.Rows(i)("Type"))
.Add(TABLE.Rows(i)("Stock"))
.Add(TABLE.Rows(i)("Leverancier"))
.Add(TABLE.Rows(i)("Barcode"))
.Add(TABLE.Rows(i)("MinStuks"))
.Add(TABLE.Rows(i)("Omschrijving"))
.Add(TABLE.Rows(i)("Merk"))
.Add(TABLE.Rows(i)("Opmerking"))
End With
End With
Next
End If
End Sub
私は完全に道に迷ってしまいました。
ご挨拶