vb中查询数据库

来源:百度知道 编辑:UC知道 时间:2024/06/07 07:51:38
我设置了在一段时间内查询,查出来有很多条,我想把查出来其中一个值放到一个变量里,在很多条里,这个值都不太一样,可是赋给的这个变量,怎么总是第一条里的那个值啊?
Adodc2.RecordSource = "select 计费方身份识别 from 最终话单 where 应答日期时间 between '" & DTPicker1.Value & "' and '" & DTPicker2.Value & "' "
Adodc2.Refresh
temp = Adodc2.Recordset.Fields("计费方身份识别")

我要根据temp的不同,在datagride里放不同的数据的,那怎么办啊?

有很多条的,这样显示就是第一条了。
显示全部数据

do while not Adodc2.Recordset.eof
temp=temp & vbcrlf & Adodc2.Recordset.Fields("计费方身份识别")
Adodc2.Recordset.movenext
loop

print temp