如何判断一个查询记录为空?若为空时该如何避免错误的发生? 如果查询得到的一个记录集Rst不为空,可以正确的处理数据;若查询得到的数据集Rst为空的话,我们还能对数据集做些什么????GetRecordCount()是调用不得啊!!该如何判断Rst是否为空?谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 if(Rst != NULL){ // do } To:windyloft我是指数据集中所包含的记录个数Rst!=NULL?????//好像不能用于判断记录个数是否为空吧! if(VARIANT_FALSE == m_pRs->EndOfFile) //有纪录选出才操作 { ...... } if (!g_Connection->IsOpen()) { return FALSE; } strQuery = "Select * from GroupList"; g_RecordSet->SetAdoConnection(g_Connection); if (g_RecordSet->Open(strQuery) == -1) { m_strErr = g_RecordSet->GetLastError();// AfxMessageBox(m_strErr); return FALSE; } m_GroupCnt = g_RecordSet->GetRecordCount(); while(!g_RecordSet->IsEOF()) { ...... } TO:alon21(飘一族.Alon)、 kvw3000(回家念经)sCondition.Format("Template_Id='%s'","mb001");oRecordset->Filter=(LPCSTR)sCondition;若是在过滤后的结果为多个记录,则各位的方法运行正确!可是若过滤的结果为0个记录,则对RecordCount/GetRecordCount/MoveFirst/EndOfFile的调用都会出现致命错误;现在关键问题是如何才能知道过滤后的记录为0个记录!谢谢各位啊! 不会吧,我这样满好的呀 RecordCount = m_pRecordset->RecordCount; if(RecordCount==0) { return 0; } if(Rst->adoEOF==VARIANT_TRUE)it means that there is no records in the request;also you can use RecordCount = m_pRecordset->RecordCount; if(RecordCount==0) { return 0; }but before that you must make sure you do the below thing:Rst->CursorLocation=adUseClient; 趁五一散个分,节前结贴 关于打印尺寸的获取 尽管只有20分了,但我忠心的祝福全天下的女生节日快乐! DirectShow下帧图像捕捉的问题 我想用use,pass和数据库表Label1中,username,pid比较,找到相同的怎么作啊 关于使用标签视后菜单消息命令的奇怪问题(高分重谢) ××× 项目要失败了,合同没有标明 违约金 是多少? 有没有默认的违约金? 怎样才能让我赔偿的最少?××× 请教CRuntimeClass的问题 简单问题 这个上三角是什么运算付“^” 请教vc中,如何在指定文件的指定位置插入一个参数值; dll中的dialog如何实现toolbar?
{
// do
}
我是指数据集中所包含的记录个数
Rst!=NULL?????//好像不能用于判断记录个数是否为空吧!
{
......
}
{
return FALSE;
}
strQuery = "Select * from GroupList";
g_RecordSet->SetAdoConnection(g_Connection);
if (g_RecordSet->Open(strQuery) == -1)
{
m_strErr = g_RecordSet->GetLastError();
// AfxMessageBox(m_strErr);
return FALSE;
} m_GroupCnt = g_RecordSet->GetRecordCount();
while(!g_RecordSet->IsEOF())
{
......
}
oRecordset->Filter=(LPCSTR)sCondition;
若是在过滤后的结果为多个记录,则各位的方法运行正确!可是若过滤的结果为0个记录,则对RecordCount/GetRecordCount/MoveFirst/EndOfFile的调用都会出现致命错误;
现在关键问题是如何才能知道过滤后的记录为0个记录!谢谢各位啊!
RecordCount = m_pRecordset->RecordCount;
if(RecordCount==0)
{
return 0;
}
it means that there is no records in the request;
also you can use
RecordCount = m_pRecordset->RecordCount;
if(RecordCount==0)
{
return 0;
}
but before that you must make sure you do the below thing:
Rst->CursorLocation=adUseClient;