在使用ado处理大量ACCESS97数据后,总是报错:3167:“record is deleted”,如何解决?

power401102 2008-05-13 07:42:19
access数据库中存在3个表有效数据表A,全部数据表B,无效数据表C ,在修改了有效数据表A后,为了更新B和C,操作如下:

1.清空B,C;
2.以for i=1 to n 的方式顺序判断A中是否有符合和i相关的数据(说明:A和C中含有与i无关的数据)
3.没有符合条件的情况:则插入到C中,同时也插入B中
4.有符合条件的情况:则插入到B中

完成操作后,分别显示A,B,C是报错:3167:“record is deleted”

不知为何?是因为数据量大的原因吗(两三万条)?
...全文
303 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
power401102 2008-05-14
  • 打赏
  • 举报
回复
在显示前对数据库刷新后正常,:)
饮水需思源 2008-05-13
  • 打赏
  • 举报
回复
对数据库进行增加、修改或删除操作后先关闭已经打开的记录集,再重新打开试试
power401102 2008-05-13
  • 打赏
  • 举报
回复
刚到msdn上查了一下:http://support.microsoft.com/kb/208799/en-us/

贴出来一块研究一下:
SYMPTOMS
When you add a record to an SQL table using Visual Basic for Applications, if the table's unique index field has a default value, and you do not assign a value to that field, the new record appears deleted until you reopen the SQL table. If you try to obtain a value from the new record, you receive the following error message:

Run-time error '3167'
Record is deleted.


RESOLUTION
To resolve this behavior, when you open the SQL table by using Visual Basic code, include the dbSeeChanges option, as in the following example:

Set rs = db.OpenRecordset("TestTable", dbOpenDynaset, dbSeeChanges)

The dbSeeChanges option ensures that any newly added records that contain a default value in the unique index field are available in the current recordset.
power401102 2008-05-13
  • 打赏
  • 举报
回复
放了一上午,无人问津
lidaixiang 2008-05-13
  • 打赏
  • 举报
回复
不像是数据量大的问题。应该是操作中,某条数据不符号当前操作规则。
建议您在数据库中按预定规则建立几条数据,再在程序中写上监控执行的语句,或是设定中断,来看运行是否正常。这样很容易查出问题来的。
power401102 2008-05-13
  • 打赏
  • 举报
回复
关闭记录集试过了,不行;msdn上的方法也试过了,也不行。

重启系统后数据正常,是删除和插入后所要得的数据。

到底是什么原因啊?曾怀疑过是数据量的问题,也怀疑是操作数据和显示数据不在同一窗体的问题,我都编制小程序模拟过了,可以正常显示,为何在原系统中总报错呢?

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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