vb6.0+Access数据库实现查询功能,通过选择查询条件,将数据库中符合条件的数据显示在表格中。

2024-11-30 11:00:32
推荐回答(2个)
回答1:

Private Sub RIQI()
str = "select * from 传感器融合"
Rs.Open str, Conn, 1, 3
For j = 1 To Rs.RecordCount
If Rs.Fields(2) = Text2.Text Then
Dim Fliv As ListItem
Set Fliv = ListView1.ListItems.Add(, , "")
Fliv.Text = Rs.Fields(0)
Fliv.SubItems(1) = Rs.Fields(1)
Fliv.SubItems(2) = Rs.Fields(2)
Fliv.SubItems(3) = Rs.Fields(3)
End If
Rs.MoveNext
Next j
Rs.Close
End Sub
在连接好数据库后,查询数据,并将其显示在listview控件中,希望对你有帮助

回答2:

Dim sqlstr As String
Dim t_code As String
sqlstr = "SELECT * FROM table
if t_code <> ""
sqlstr = sqlstr + "where A =" & T_code
endif