Access 2007 - INSERT and instant SELECT doesn't retrieve the inserted data

依然范特西╮ 提交于 2019-11-27 16:22:26

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

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

  2. 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.

  3. 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.

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.

(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.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!