设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

2个办法解决文件共享锁定数溢出3052错误的问题

2005-5-16 00:00| 发布者: tmtony| 查看: 1447| 评论: 2|原作者: tmtony|来自: Access中国

摘要: Public Function abc() On Error GoTo Err_Cmdls_Click CurrentDb.Execute update 电视剧整理 set 临时='' Dim Rs As New ADODB.Recordset Dim date1 As Date Dim date2 As Date Dim str1 As String ...

复制数据或有时Access代码为什么出现"文件共享锁定数溢出3052"错误

有两个方法解决:

1.修改注册表 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\3.5\Engines\Jet 3.5 (如果是4.0版本改为4.0) 将MaxLocksPerFile改到足够大 (但注意也不要太贪心

2.在运行你的程序之前运行下面的函数:
Sub LargeUpdate()
      On Error GoTo LargeUpdate_Error
      Dim db As Database, ws As Workspace

      ' Set MaxLocksPerFile.
      DBEngine.SetOption dbMaxLocksPerFile, 200000

      Set db = CurrentDb
      Set ws = Workspaces(0)

      ' Perform the update.
      ws.BeginTrans
      db.Execute "UPDATE LargeTable SET Field1 = 'Updated Field'", _
         dbFailOnError
      ws.CommitTrans

      db.Close
      MsgBox "Done!"
      Exit Sub

   LargeUpdate_Error:

      MsgBox Err & " " & Error
      ws.Rollback
      MsgBox "Operation Failed - Update Canceled"
      Exit Sub

   End Sub

相关阅读

发表评论

最新评论

引用 haemon 2005-5-16 20:34
最好是附上数据库
引用 tmtony 2005-5-19 06:55
有两个方法解决:

1.修改注册表 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\3.5\Engines\Jet 3.5 (如果是4.0版本改为4.0) 将MaxLocksPerFile改到足够大 (但注意也不要太贪心

2.在运行你的程序之前运行下面的函数:
Sub LargeUpdate()
      On Error GoTo LargeUpdate_Error
      Dim db As Database, ws As Workspace

      ' Set MaxLocksPerFile.
      DBEngine.SetOption dbMaxLocksPerFile, 200000

      Set db = CurrentDb
      Set ws = Workspaces(0)

      ' Perform the update.
      ws.BeginTrans
      db.Execute "UPDATE LargeTable SET Field1 = 'Updated Field'", _
         dbFailOnError
      ws.CommitTrans

      db.Close
      MsgBox "Done!"
      Exit Sub

   LargeUpdate_Error:

      MsgBox Err & " " & Error
      ws.Rollback
      MsgBox "Operation Failed - Update Canceled"
      Exit Sub

   End Sub

查看全部评论(2)

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-4-25 14:49 , Processed in 0.087961 second(s), 24 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部