2010-05-14 34 views
0

多個值,我得到的一些數據:顯示與點域ADODB

rs.Filter = "datapath='" + dpath + "' and analystname='" + aname + "' and reportname='" + rname + "' and batchstate='" + bstate + "'" 
If Not rs.EOF Then 
    MsgBox rs.Fields("rowid") 
End If 

如果rs.filter返回多條記錄,請問如何rs.fields("rowid")給我多的rowid值?

回答

2
do while not (rs.eof and not rs.bof) 

    MsgBox rs.Fields("rowid") 
    rs.movenext() 

end while 

語法可能是錯誤的,但多數民衆贊成這個想法。

+0

哎gratzy非常感謝你的回答可以請你結合我的代碼到你的答案,作爲即時通訊不知道它應該去 – 2010-05-14 16:32:24

1

如果您只是簡單地調用rs.Fields("rowId"),那麼實際上是要求可能是第一行的當前行的列值。假設記錄集返回10行,你想要對每個行的rowId值做什麼?在消息框中分別顯示它們?這意味着10個消息框。如果這真的是你想要做什麼,你會做這樣的事情:

rs.Filter = "datapath='" + dpath + "' and analystname='" + aname + "' and reportname='" + rname + "' and batchstate='" + bstate + "'" 
Do Until rs.EOF 
    MsgBox rs.Fields("rowid").Value 
    rs.MoveNext 
Loop 

這假定rs是一個只進記錄。如果您使用的是鍵集遊標,那麼您可能必須調用MoveFirst()。第一

MsgBox rs.GetString 

檢查返回了一些記錄:

rs.Filter = "datapath='" + dpath + "' and analystname='" + aname + "' and reportname='" + rname + "' and batchstate='" + bstate + "'" 
rs.MoveFirst() 
Do Until rs.EOF 
    MsgBox rs.Fields("rowid").Value 
    rs.MoveNext 
Loop