VB如何查找到数据库中符合条件数据所在的行号?

来源:百度知道 编辑:UC知道 时间:2024/05/14 18:56:30
Dim name As String
name = InputBox("请输入要查找的员工姓名:")
sql = "select * from 员工信息 where 姓名='" & name & "' "
Set qy1 = cnn.Execute(sql)

本身没有设行号这一字段.但我想通过MsgBox显示所找到的信息处在表中第几行.

望高手帮助!谢谢!!!
用的是DRID控件.

你可以用这种写法:

Dim name As String
dim n as in integer
Public zg As New ADODB.Recordset
set zg=new adodb.recordset
name = InputBox("请输入要查找的员工姓名:")
sql = "select * from 员工信息 where 姓名='" & name & "' "
cnn.open
zg.open sql,cnn,2,2
do while not zg.eof
n=n+1
if zg("姓名")=name then exit do
zg.movenext
loop
if not zg.eof then
msgbox "记录在第:"& n &"行!",vbokonly,"提示"
endif

你试试