请教高手:Oracle中ADO查询记录是否存在的问题
.......
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返回的是什么东西?