Access数据库事务插入限制 [英] Access DB Transaction Insert limit

查看:644
本文介绍了Access数据库事务插入限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有插入你需要提交或Access /喷气抛出一个错误之前?

Is there a limit to the amount of inserts you can do within an Access transaction before you need to commit or before Access/Jet throws an error?

我才可以访问事务中做量的限制目前米运行下面的代码,希望确定这个最大是什么。

I'm currently running the following code in hopes to determine what this maximum is.

OleDbConnection cn =
                new OleDbConnection(
                    @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\myAccessFile.accdb;Persist Security Info=False;");
            try
            {
                cn.Open();
                oleCommand = new OleDbCommand("BEGIN TRANSACTION", cn);               
                oleCommand.ExecuteNonQuery();    
                oleCommand.CommandText =
                            "insert into [table1] (name) values ('1000000000001000000000000010000000000000')";

                for (i = 0; i < 25000000; i++)
                {
                    oleCommand.ExecuteNonQuery();
                }                

                oleCommand.CommandText = "COMMIT";
                oleCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {

            }
            finally
            {
                try
                {

                    oleCommand.CommandText = "COMMIT";
                    oleCommand.ExecuteNonQuery();                    
                }

                catch{}

                if (cn.State != ConnectionState.Closed)
                {
                    cn.Close();
                }
            }



我在生产应用程序接收到的时候我达到错误2333920镶在一个未提交的事务是:文件共享锁计数超出增加MaxLocksPerFile注册表项。禁用固定这个问题的交易。

The error I received on a production application when I reached 2,333,920 inserts in a single uncommited transaction was: "File sharing lock count exceeded. Increase MaxLocksPerFile registry entry". Disabling transactions fixed this problem.

推荐答案

是的,其实也有一个极限。而你已经清楚地达到了它。每微软的文档

Yes, there is in fact a limit. And you've reached it clearly. Per Microsoft's documentation:

如果要进行交易所需的锁数超过每个文件的最大锁数,就会发生错误。

The error occurs if the number of locks required to perform a transaction exceeds the maximum number of locks per file.

在该链接有一些变通办法。第二个是比较现实的,它临时改变最大的锁。

At that link there are a couple of workarounds. The second one is more realistic, it changes the max locks temporarily.

这篇关于Access数据库事务插入限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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