我们正在尝试根据某些条件获取特定记录集的行号。考虑下表
Name Id
abc 1
cde 2
efg 3
现在,如何获取员工“cde”的行号或记录集号(根据下面的代码,我们需要得到结果为 2)。请对此有任何帮助。
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H0001
strSource="C:\Test.xls"
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strSource & ";Extended Properties=""Excel 8.0;HDR=Yes;"";"
Set conn = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
conn.Open strConnection
objRecordset.Open "Select Name FROM [sheet1$] Where Id = 2", conn, adOpenStatic, adLockOptimistic, adCmdText
msgbox objRecordset.GetString
conn.Close
Set conn = Nothing