CDaoRecordset.movenext()的一个简单问题

duanhuei 2008-06-02 02:03:10
在VC中,在一个查询中用dao查询,其中用了一个函数进行子查询操作,
while(!RecSet3.IsEOF()) // 有没有到表结尾
{
RecSet3.GetFieldValue("cresub",var);
s= (LPCSTR)var.pbstrVal;
...
fun(a);
RecSet3.MoveNext();
}
其中fun()函数也用到了相同的查询,当然定义的CDaoRecordset RecSet2用的是不一样的参数(这没影响),再返回到此函数时,明明已经到了最后一条记录,但还是继续向下走,再读取时发生错误,提示到"记录已删除",请问怎么解决.
或者告诉我怎么判断当前RECSET所指记录是否不存在,我查了MSDN好像没有,ISDELETE不行.
谢谢大家了
...全文
64 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
duanhuei 2008-06-02
  • 打赏
  • 举报
回复
RecSet3.Open(AFX_DAO_USE_DEFAULT_TYPE,sql,NULL);
这么打开的,
没有人回么,楼上贴的是ISDETELE的定义么
shakaqrj 2008-06-02
  • 打赏
  • 举报
回复
用什么方式打开的?
Call this member function to determine whether the current record has been deleted. If you scroll to a record and IsDeleted returns TRUE (nonzero), then you must scroll to another record before you can perform any other recordset operations.

Note You don't need to check the deleted status for records in a snapshot or table-type recordset. Because records cannot be deleted from a snapshot, there is no need to call IsDeleted. For table-type recordsets, deleted records are actually removed from the recordset. Once a record has been deleted, either by you, another user, or in another recordset, you cannot scroll back to that record. Therefore, there is no need to call IsDeleted.

When you delete a record from a dynaset, it is removed from the recordset and you cannot scroll back to that record. However, if a record in a dynaset is deleted either by another user or in another recordset based on the same table, IsDeleted will return TRUE when you later scroll to that record.

duanhuei 2008-06-02
  • 打赏
  • 举报
回复
感谢你的回复,问题用另一种笨法解决的,把要FUN的记录的信息存储起来,在循环外再进行FUN(删除),很笨但能实现.
我感觉在子查询中使用.Delete();会造成RecSet的指向记录的指针发生混乱.所以不行.
ISDELETE呢好像是把删除过记录的位置都记录下来,不能实现我的要求.
唉,问题先这么的吧,以后不用DAO了,有点落后.
分给你,谢谢了
duanhuei 2008-06-02
  • 打赏
  • 举报
回复
补充一下,fun完成的功能是删除一条记录,我估计父查询中可能指向一条已经删除的记录,怎么样解决呢,跳过么?
shakaqrj 2008-06-02
  • 打赏
  • 举报
回复
dbOpenDynaset A dynaset-type recordset with bidirectional scrolling. This is the default

When you delete a record from a dynaset, it is removed from the recordset and you cannot scroll back to that record. However, if a record in a dynaset is deleted either by another user or in another recordset based on the same table, IsDeleted will return TRUE when you later scroll to that record.

都是msdn上的
不知道func里面到底是什么

4,011

社区成员

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

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