各位大侠,小弟在使用记录集的recordcount时总是出错!!!
开始时得到-1,在其他地方看到的的解决方法是
rs.open strsql,connect,1,1
结果试了,有时可以有时不好用,但是如果打开数据库并打开要查询的表就好用了!!
我使用的数据库是sybase sql anywhere
请各位赐教!!!
开始时得到-1,在其他地方看到的的解决方法是
rs.open strsql,connect,1,1
结果试了,有时可以有时不好用,但是如果打开数据库并打开要查询的表就好用了!!
我使用的数据库是sybase sql anywhere
请各位赐教!!!
rs.open strsql,connect,3,3
试一下
connect.CursorLocation = adUseClient
...
rs.open strsql,connect,1,1在读记录集条数时,游标需要设成客户端的,否则即便有记录,recordcount也会显示为-1。
这一句是最关键的!
游标需要设成客户端的
rs.open "select * from tablename",conn,adopenkeyset,adlockreadonly
if rs.recordcount>0 then
rs.movelast
rs.movefirst
msgbox rs.recordcount
end if
set rs=nothing