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控件中,希望对你有帮助
Dim sqlstr As String
Dim t_code As String
sqlstr = "SELECT * FROM table
if t_code <> ""
sqlstr = sqlstr + "where A =" & T_code
endif