怎样获得ado 调用返回的记录条数,解决了就给分

执行一个查询语句之后,想知道返回了多少条记录,该怎么办,哪位有代码,帮个忙先
---------------------------------------------------------------

rs.movelast
rs.movefirst
rs.recordcount
就肯定没问题了
---------------------------------------------------------------

同意楼上
---------------------------------------------------------------

recordset.open sql, conn, 1,1

or

recordset.open sql, conn, 3,1

then use
recordset.recordcount
---------------------------------------------------------------

同意carrotbill
---------------------------------------------------------------

rs.movelast
rs.movefirst
rs.recordcount
就肯定没问题了
这是老的DAO的BUG

Set OpenRecordsetWithConnect = New ADODB.Recordset
Set OpenRecordsetWithConnect.ActiveConnection = cnn
OpenRecordsetWithConnect.CursorLocation = adUseClient
OpenRecordsetWithConnect.CursorType = adOpenStatic '使用静态游标
OpenRecordsetWithConnect.LockType = adLockOptimistic '使用乐观锁
OpenRecordsetWithConnect.Open sSql
Debug.Print OpenRecordsetWithConnect.RecordCount

关键是这两句

OpenRecordsetWithConnect.CursorType = adOpenStatic '使用静态游标
OpenRecordsetWithConnect.LockType = adLockOptimistic '使用乐观锁

---------------------------------------------------------------

错了:),应该是关键这两句
OpenRecordsetWithConnect.CursorLocation = adUseClient
OpenRecordsetWithConnect.CursorType = adOpenStatic '使用静态游标
---------------------------------------------------------------

rs.open "Suppliers", conn, adOpenForwardOnly, adLockReadOnly
rssuppliers.RecordCount
---------------------------------------------------------------

你可改为用如下SQL语句建立记录集:
select count(*) from customer

条件不同,结果相应改变,更加通用了
你同意吗?朋友

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus