Ado的Recordset为何获取记录条数为-1

dengjiang1999 2003-10-14 09:28:36
代码如下
int iCount;
m_pRecordSet->MoveLast();
iCount = m_pRecordSet->RecordCount;
m_pRecordSet->Close();
为什么iCount为-1,马上给分
...全文
102 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
jkljf 2003-10-15
  • 打赏
  • 举报
回复
不要用adForwardOnly的游标类型阿
Jackyjiajing 2003-10-15
  • 打赏
  • 举报
回复
游标设置为aduseserver是得不到记录集RecordCount的
dhbo 2003-10-15
  • 打赏
  • 举报
回复
应该把游标设置为:
aduseclient
quanch 2003-10-15
  • 打赏
  • 举报
回复
cursor设置不对,CursorLocation = adUseServer或CursorLocation = adUseClient,试试吧!另外RecordSet在Open时用adOpenStatic。
丁淇石头 2003-10-14
  • 打赏
  • 举报
回复
直接MoveLast()好象没有效果,应该是MoveNext()。
个人认为,用smallcrocodile(大鳄鱼)的方法比较好些
smallcrocodile 2003-10-14
  • 打赏
  • 举报
回复
你的指针道表的末尾了!
最保险的方法是:
SELECT COUNT(COL_NAME) ICOUNT FROM TABLE_NAME
spwnihao 2003-10-14
  • 打赏
  • 举报
回复
m_pRecordset->GetRecordCount()
得到的数是结果集移动过的数据
双杯献酒 2003-10-14
  • 打赏
  • 举报
回复
GZ
spwnihao 2003-10-14
  • 打赏
  • 举报
回复
int iCount;
m_pRecordSet->MoveLast();
m_pRecordSet->MoveFirst();
iCount=m_pRecordset->GetRecordCount();
AkiraChing 2003-10-14
  • 打赏
  • 举报
回复
The cursor type of the Recordset object affects whether the number of records can be determined. The RecordCount property will return -1 for a forward-only cursor; the actual count for a static or keyset cursor; and either -1 or the actual count for a dynamic cursor, depending on the data source.

动态集根据数据源,或者返回-1或者返回实际数目吗;forward-only 返回-1;static or keyset 返回实际数目
agent 2003-10-14
  • 打赏
  • 举报
回复
iCount为-1应该有多种可能的情况,可能是对forward-only cursor进行操作,也可能是cursor的类型不支持吧。

4,017

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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