我有一个基本问题。我有一个访问数据库,其中我有一个包含2列的List2。我有一个输入框,我扫描条形码编号,我想在第1列(名称标题 - Zak)中搜索此条形码编号,如果在列中找到此条形码然后显示我在同一行的第2列(名称标题Cisl)值条码。我有一部分代码,我不知道如何继续。谢谢你的帮助
Private Sub PictureBox12_Click(sender As Object, e As EventArgs) Handles PictureBox12.Click
Dim barcode As String = Nothing
Dim foundRows() As Data.DataRow
barcode = InputBox("Naskenujte čárový kód ||||||||||||||||||||||||||||||||||||")
If Len(Trim(barcode)) = 0 Then Exit Sub 'Pressed cancel
'Vytvoreni dotazu
foundRows = SdfDataSet.Tables("List2").Select("[Zak] = '" & barcode & "'")
If foundRows IsNot Nothing Then
MsgBox("Nenalezeno")
Else
MsgBox("Zákaznické číslo: " & barcode & foundRows(0)("Cisl"))
End If
End Sub
答案 0 :(得分:0)
就是这样:
'Get the Row with the barcode.
Dim foundRows() As Data.DataRow
foundRows = DataSet1.Tables("List1").Select("[Zak] = '" & barcode & "'")
If foundRow IsNot Nothing Then
'If not Found do something here or not.
Else
'If found output the first found rows Column2
MsgBox("Zákaznické číslo: " & barcode & foundRow(0)("Column2"))
End If
注意:将 Column2 替换为列名。