Access 2007年 - INSERT和即时选择不检索插入的数据 [英] Access 2007 - INSERT and instant SELECT doesn't retrieve the inserted data

查看:132
本文介绍了Access 2007年 - INSERT和即时选择不检索插入的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在通过OLEDB表中插入几行,并选择即时插入的行。

I'm inserting a few rows in a table via OleDB, and select instantly the inserted row.

我不能检索这样的行,我要等待约3-5秒。然后在插入的行会出现在表格中。

I can't retrieve the row in this way, i have to wait for approx. 3-5 seconds. And then the inserted row appears in the table.

我观察到在数据库本身这种行为,我插通过OLEDB行和访问看着打开的表。在表中的行出现3-5秒后

I observed this behavior in the database itself, i inserted the row via OleDB and watched the opened table in Access. The row appeared 3-5 seconds later in the table.

请问访问缓存行?我一定要通过OLEDB发送冲洗或承诺,等?

Does Access buffer rows? Do i have to send a flush or commit, etc. via OleDB ?

任何建议将是非常有益的。

Any suggestions would be very helpful.

(请不要问我为什么不通过我的业务逻辑或其他方式解决这个问题......)

(Please don't ask why I don't solve this through my business logic or other ways....)

推荐答案

我做了一些测试,并有似乎是一些缓冲与ACE OleDb的事情。我发现,

I did some testing and there does seem to be some buffering going on with ACE OleDb. I found that

  1. 如果我做了一些INSERT语句,然后立即做了一个选择同一个OleDbConnection的新行可用的时候了。

  1. If I did some INSERTs and then immediately did a SELECT on the same OleDbConnection the new rows were available right away.

如果我开了两个OleDbConnection的对象,插在 con 1的,然后立即上选择 CON2 的新行了约5秒钟,成为可用的 CON2 连接上。

If I opened two OleDbConnection objects, INSERTed on con1, and then immediately SELECTed on con2 the new rows took approximately 5 seconds to become available on the con2 connection.

如果我开了两个OleDbConnection的对象,插在 con 1的,没有 con1.Close(),然后立即上选择 CON2 新行可用的时候了。

If I opened two OleDbConnection objects, INSERTed on con1, did con1.Close(), and then immediately SELECTed on con2 the new rows were available right away.

因此​​,看来在关闭的OleDbConnection具有冲洗的写操作,使它们对其它连接越早可用的效果。我的猜测是,OleDb的是隐式缓冲(或配料)的更新,因为ACE / Jet是一个共享文件,数据库和它正试图减少对数据库文件的争夺。

So, it appears that closing the OleDbConnection has the effect of "flushing" the writes and making them available to other connections sooner. My guess is that OleDb is implicitly buffering (or "batching") updates because ACE/Jet is a shared-file database and it is trying to reduce the contention on the database file.

(当我使用SQL Server也做了同样的测试有,当我关闭 con 1的的情况下,当我离开它打开的情况之间没有显著差异。在任何情况下新纪录是立即可用。)

(When I did the same test using SQL Server there was no significant difference between the case when I closed con1 and the case when I left it open. In every case the new records were available instantly.)

这篇关于Access 2007年 - INSERT和即时选择不检索插入的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆