VB ,从数据库中读取值赋给数组
Dim lRs4 As New ADODB.Recordset
lRs4.Open "select count(*) as num from fz_sk_join1 where operate_id=" & mOperate_id & " group by small_id having count(*)>1", gCnSk, adOpenStatic, adLockReadOnly
Dim count() As Integer
ReDim count(lRs4.RecordCount)
While Not lRs4.EOF
count(lRs4.AbsolutePosition) = lRs2("num")
lRs4.MoveNext
Wend
问题在count(lRs4.AbsolutePosition) = lRs2("num")这句话,运行的时候显示在对应所需名称或序数的集合中未找到项目
,而我的SQL语句select count(*) as num from fz_sk_join1 where operate_id=" & mOperate_id & " group by small_id having count(*)>1在SQLServer中运行正确
我应该怎么将查询出来的结果赋给count()数组呢?
[解决办法]
问题可能出在AbsolutePosition。
数组是0-based; AbsolutePosition是1-based。
你改成 count(lRs4.AbsolutePosition - 1) = lRs2("num") 试试