首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

VB中对rs产生的结果处理,该如何处理

2012-03-08 
VB中对rs产生的结果处理Rs.Open select FItemID as FAuxprice from Icstockbillentry t1 + vbLf + _whe

VB中对rs产生的结果处理
Rs.Open "select FItemID as FAuxprice from Icstockbillentry t1" + vbLf + _
  "where t1.FInterID='1938' "
   
  If Rs.RecordCount > 0 Then '如果查询结果存在记录
  FAuxprice = Rs("FAuxprice")
   
  MsgBox FAuxprice
  Else '查询结果不存在记录
  FAuxprice = 0
  End If
  Rs.Close

  其中Rs有多条记录,我想对这个结果集所有的记录放在一个组内,用For语句遍历这些记录


[解决办法]

VB code
dim i as longRs.Open "select FItemID as FAuxprice from Icstockbillentry t1" + vbLf + _  "where t1.FInterID='1938'",conn,adopenkeyset,adlockreadonly    If Rs.RecordCount > 0 Then '如果查询结果存在记录    for i=1 to rs.recordcount        tmp(i-1)=rs!FAuxprice        rs.movenext    next iElse '查询结果不存在记录    FAuxprice = 0End IfRs.Close
[解决办法]
dim i as long
dim tmp() as long
Rs.Open "select FItemID as FAuxprice from Icstockbillentry t1" + vbLf + _
"where t1.FInterID='1938'",conn,adopenkeyset,adlockreadonly

with rs

If not .eof Then '如果查询结果存在记录
do while Not .EOF 
tmp(i)=.Fields("FAuxprice")
i=i+1
rs.movenext
Loop
Else '查询结果不存在记录
FAuxprice = 0
End If


end with

Rs.Close

热点排行