请教高手关于记录集的问题,急!!!

njyhg 2003-08-24 11:03:33
各位大侠,小弟在使用记录集的recordcount时总是出错!!!
开始时得到-1,在其他地方看到的的解决方法是
rs.open strsql,connect,1,1
结果试了,有时可以有时不好用,但是如果打开数据库并打开要查询的表就好用了!!
我使用的数据库是sybase sql anywhere
请各位赐教!!!
...全文
48 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
饮水需思源 2003-08-25
  • 打赏
  • 举报
回复
if rs.state=adstateopen then rs.close
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
hzybc 2003-08-24
  • 打赏
  • 举报
回复
加上这句 :CN.CursorLocation = adUseClient

改成
rs.open strsql,connect,3,3
试一下
KJ_Wang 2003-08-24
  • 打赏
  • 举报
回复
connect.CursorLocation = adUseClient

rs.open strsql,cn,adOpenForwardOnly,adLockOptimistic

肯定行
njyhg 2003-08-24
  • 打赏
  • 举报
回复
后面的两个参数是1,1还是3,3
那位能确定一下!!!
yeah_yz 2003-08-24
  • 打赏
  • 举报
回复
rs.open strsql,connect,3,3
战箫 2003-08-24
  • 打赏
  • 举报
回复
connect.CursorLocation = adUseClient
游标需要设成客户端的
amongwang 2003-08-24
  • 打赏
  • 举报
回复
connect.CursorLocation = adUseClient
这一句是最关键的!
wumy_ld 2003-08-24
  • 打赏
  • 举报
回复
...
connect.CursorLocation = adUseClient
...
rs.open strsql,connect,1,1

在读记录集条数时,游标需要设成客户端的,否则即便有记录,recordcount也会显示为-1。
njyhg 2003-08-24
  • 打赏
  • 举报
回复
试试!!

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧