设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 2299|回复: 2
打印 上一主题 下一主题

[Access本身] 这段代码为什末出现"文件共享锁定数溢出3052"错误

[复制链接]
跳转到指定楼层
1#
发表于 2005-5-16 19:11:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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
    Dim str2 As String
    Dim xx1 As String
    Dim xx2 As String
    Dim mc1 As String
    Dim mc2 As String
    Rs.Open "电视剧整理", CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdTable
    Rs.MoveFirst
    CurrentDb.Execute "update 电视剧整理 set 临时=名称 "
    Do Until Rs.EOF
    str1 = Rs!临时
    date1 = Rs!开始日期
    xx1 = Rs!合并
    mc1 = Rs!名称
    Rs.MoveNext
    mc2 = Rs!名称
    xx2 = Rs!合并
    date2 = Rs!开始日期
    If xx1 = xx2 And date2 - date1 > 10 Then
    str2 = str1 + "-重"
    Rs!临时 = str2
    ElseIf xx1 = xx2 And date2 - date1 <= 10 Then
    Rs!临时 = str1
    Else
    Rs!临时 = mc2
    End If
    Loop
Rs.Close
Set Rs = Nothing
Exit_Cmdls_Click:
    Exit Function

Err_Cmdls_Click:
  If err.Number = 3021 Then
  MsgBox "结果已经生成!", vbInformation, "提示:"
  Resume Exit_Cmdls_Click
  End If
    MsgBox err.Description & err.Number
    Resume Exit_Cmdls_Click
   
End Function
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2005-5-16 20:34:00 | 只看该作者
最好是附上数据库

点击这里给我发消息

3#
发表于 2005-5-19 06:55:00 | 只看该作者

这段代码为什末出现"文件共享锁定数溢出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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-19 18:48 , Processed in 0.089689 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表