请教高手:Oracle中ADO查询记录是否存在的问题

windwye 2003-09-12 10:44:36
.......
char strSQL[1024];strSQL[0] = '\0';
sprintf((char*)strSQL, "select count(*) as rs_count from tiffimage");
pRecordSetPtr->PutActiveConnection(_variant_t((IDispatch *)theApp.m_pConnection,true));
_variant_t vtNULL;
vtNULL.vt=VT_ERROR;
vtNULL.scode=DISP_E_PARAMNOTFOUND;
pRecordSetPtr->Open(strSQL,vtNULL,adOpenDynamic,adLockPessimistic,adCmdText);
long tmpCount=0;
tmpCount = pRecordSetPtr->GetCollect("rs_count").lVal;
....
sprintf((char*)strSQL, "select * from tiffimage");
pRecordSetPtr->Open(strSQL,vtNULL,adOpenDynamic,adLockPessimistic,adCmdText);
long lRecordCount = pRecordSetPtr->GetRecordCount();

....
结果:
tmpCount =8;
lRecordCount =-1;

为什么lRecordCount不等于8呢??好像总等于-1;
ADO怎么查询某个字段为某条件的记录是否存在?
我试过用select count(*) as rs_count from (select * from tiffimage where id=56434;得到rs_count 的值与实际相符,但这样也太麻烦了吧?
GetRecordCount返回的是什么东西?

...全文
28 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
beckhambobo 2003-09-13
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/2243/2243810.xml?temp=.5211756
armu80830 2003-09-13
  • 打赏
  • 举报
回复
要将ado的游标类型设置为:客户端游标

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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