我在使用 Excel 2010 前端、Access 2010 后端的应用程序时遇到间歇性问题。它同时被 5-10 个用户使用。最近,用户开始间歇性地收到以下错误:Run-time error '3035': System resource exceeded.
有时调试按钮是灰色的,所以我无法跳转到导致错误的代码,但是当它可以点击时,它会将我带到以下代码:
'Open connection to back end DB
Set db = OpenDatabase(dbPath)
'Open a recordset of a table
Set RS = db.OpenRecordset(Tbl)
'loop through rows in a 2D array
For i = FR To LR
RS.AddNew
'loop through columns of the 2D array
For j = 1 to LC
'set values for various fields in the new record, using values from the array
Next
RS.Update
Next
在这里,
RS.Update
被标记为导致错误的行。奇怪的是,这个问题来来去去。用户在尝试提交某个数据集时会重复收到它,然后,几个小时后,当他们再次尝试提交相同的数据集时,操作成功且没有错误。同样令人困惑的是,有时调试按钮可用,有时不可用。
一个问题可能是 Access 后端的大小;它目前约为 650 MB,直到它增长到大约 600 MB,我们才开始收到这些消息。
关于可能导致这种情况的任何想法?各种谷歌点击表明,当连接查询具有太多字段时,有时会发生此问题,但这只是表的记录集,而不是连接查询。
最佳答案
啊,我认为这是当您向无法跟上锁定文件管理的后端数据库写入大量内容时弹出的奇怪错误之一。
解决方案是确保从每个客户端保持与后端数据库的连接打开,并保持该连接直到关闭客户端。
只需打开一个记录集到一个表(比如一个只有一条记录的虚拟表),并保持该记录集打开,直到您关闭应用程序。
在资源方面,保持此连接打开不会对性能或内存消耗产生不利影响,但它将确保不会在每次打开然后关闭连接时连续创建/删除锁定文件。
保持该连接打开也将大大increase the performance of your data access .
编辑:
使用记录集时应该更加明确,并准确指定所需的操作模式:
Set RS = db.OpenRecordset(Tbl, dbOpenTable, dbFailOnError)
或者,如果您只附加数据,速度会更快:
Set RS = db.OpenRecordset(Tbl, dbOpenTable, dbAppendOnly + dbFailOnError)
还要确保在完成附加数据后关闭记录集!:
Set RS = db.OpenRecordset(Tbl, dbOpenTable, dbAppendOnly + dbFailOnError)
With RS
'loop through rows in a 2D array
For i = FR To LR
.AddNew
'loop through columns of the 2D array
For j = 1 To LC
'set values for various fields in the new record,
'using values from the array
Next
.Update
Next
.Close
End With
Set RS = Nothing
关于vba - "System resource exceeded"更新记录集时,可能在其他点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16089759/