Results 1 to 8 of 8

Thread: [RESOLVED] Run-time Error Problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    200

    Resolved [RESOLVED] Run-time Error Problem

    I'm getting the following runtime error message:

    Run-time Error: '-2147467259(80004005)':File Sharing lock count exceeded. Increase MaxLocksPerFile registry entry.

    I get this error message on the following line of code:
    VB Code:
    1. recordSet.Fields("PICKSL") = Replace(recordSet.Fields("PICKSL"), "'", "")


    This line of code is in the following function:
    VB Code:
    1. Private Function conform(db As String) As Boolean
    2.     Set connection = New ADODB.connection
    3.     connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    4.         "Data Source= G:\Finance\Inventory Control\CycleCount\DB\CycleCount.mdb"
    5.     connection.Open
    6.     Set recordSet = New ADODB.recordSet
    7.     recordSet.Open db, connection, adOpenKeyset, adLockPessimistic, adCmdTable
    8.    
    9.     If (recordSet.EOF = False) Then
    10.         recordSet.MoveFirst
    11.        
    12.         Do Until recordSet.EOF
    13.             If (db = "TEST") Then
    14.                 [B]recordSet.Fields("PICKSL") = Replace(recordSet.Fields("PICKSL"), "'", "")[/B]
    15.                 recordSet.Fields("SLOT") = Replace(recordSet.Fields("SLOT"), "'", "")
    16.                 recordSet.Fields("RES") = Replace(recordSet.Fields("RES"), "'", "")
    17.                 recordSet.Fields("PROD") = Replace(recordSet.Fields("PROD"), "'", "")
    18.                 recordSet.Fields("DESC") = Replace(recordSet.Fields("DESC"), "'", "")
    19.                 recordSet.Fields("PACK") = Replace(recordSet.Fields("PACK"), "'", "")
    20.                 recordSet.Fields("MANU ID") = Replace(recordSet.Fields("MANU ID"), "'", "")
    21.                 recordSet.Fields("HITIX") = Replace(recordSet.Fields("HITIX"), "'", "")
    22.                 recordSet.Fields("PALLET ID") = Replace(recordSet.Fields("PALLET ID"), "'", "")
    23.            
    24.                 reSizeDesc (recordSet.Fields("DESC"))
    25.                 reSizeManUID (recordSet.Fields("MANU ID"))
    26.             ElseIf (db = "PICKSL") Then
    27.                 recordSet.Fields("PICKSL") = Replace(recordSet.Fields("PICKSL"), "'", "")
    28.                 recordSet.Fields("HITI") = Replace(recordSet.Fields("HITI"), "'", "")
    29.                 recordSet.Fields("PACK") = Replace(recordSet.Fields("PACK"), "'", "")
    30.                 recordSet.Fields("DESC") = Replace(recordSet.Fields("DESC"), "'", "")
    31.                 recordSet.Fields("MANUID") = Replace(recordSet.Fields("MANUID"), "'", "")
    32.                 recordSet.Fields("PROD") = Replace(recordSet.Fields("PROD"), "'", "")
    33.                            
    34.                 reSizeDesc (recordSet.Fields("DESC"))
    35.                 reSizeManUID (recordSet.Fields("MANUID"))
    36.             End If
    37.            
    38.             recordSet.MoveNext
    39.             DoEvents
    40.         Loop
    41.     End If
    42.    
    43.     recordSet.Close
    44.     connection.Close
    45.     Set recordSet = Nothing
    46.     Set connection = Nothing
    47.    
    48.     conform = True
    49. End Function

    Any help would be greatly appreciated. Thank you.

    Nenio foriras ĝis ĝi havas instru ni kiu ni devas scii.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Run-time Error Problem

    The only thing I can see that may be causing issues is the use of "connection" and "recordSet" as variable names - as they are also the data types of those variables.

    I would strongly recommend changing the names, it may well solve the problem.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    200

    Re: Run-time Error Problem

    Unfortunately I have been using connection and recordset as variable names throughout my program and it has not yet been problematic. However, I did try to run my program with difference variable names and I am still getting the same error message:

    Run-time Error: '-2147467259(80004005)':File Sharing lock count exceeded. Increase MaxLocksPerFile registry entry.

    If anyone has any suggestions I would be greatly appreciative. Thank you.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Run-time Error Problem

    Do you always open a new connection when you open a recordset?

    It may be that you several open at the time, and have reached the point where the number of avaiable connections has run out. I'm dubious that is the case, but it is a possibility.

    It is perfectly fine to have just one connection object, which stays open throughout the life of the application, and is used by of your recordsets.


    What are "reSizeDesc" and "reSizeManUID"? I presume they are subs, in which case you are calling them incorrectly - brackets around the parameters should only be used if you are using the Call keyword.

    There is also the possibility that they are causing an issue, but to be able to tell we would need to see their code.



    edit: I've just noticed that all this sub does is remove apostrophe characters from data.. are you really sure that is what you want to do?
    (I know they can cause issues, but that is only if you are building SQL statements with their values)

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    200

    Re: Run-time Error Problem

    When this function is called the connection is the only connection to the database. However, right before I called a function that deleted the contents of a table in the database. Here's the code for that function:
    VB Code:
    1. 'CLEARDATABASE()***************************************************************
    2. Private Sub clearDatabase(db As String)
    3.     Dim sql As String
    4.    
    5.     Set newConnection = New ADODB.connection
    6.     newConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    7.         "Data Source= G:\Finance\Inventory Control\CycleCount\DB\cycleCount.mdb"
    8.     newConnection.Open
    9.     Set newRecordSet = New ADODB.recordSet
    10.    
    11.     sql = "DELETE * FROM [" & db & "]"
    12.  
    13.     newRecordSet.Open sql, newConnection, adOpenKeyset, adLockPessimistic, adCmdText
    14.        
    15.     Set newRecordSet = Nothing
    16.     Set newConnection = Nothing
    17. End Sub
    18. 'ENDOF*CLEARDATABASE()*********************************************************

    After this function is called a sub is called:

    VB Code:
    1. 'WAIT()************************************************************************
    2. Private Function wait() As Boolean
    3.     Dim i As Long
    4.     For i = 0 To 10500
    5.         Dim j As Long
    6.         For j = 0 To 10000
    7.             DoEvents
    8.         Next j
    9.         DoEvents
    10.     Next i
    11.    
    12.     wait = True
    13. End Function
    14. 'ENDOF*WAIT()******************************************************************

    I do this because the connection to the database in clearDatabase() is not broken soon enough and will generate an error saying that there is still a connection to the database. Therefore, wait() allows time for the connection to the database to break.

    Then my function conform() is called to take the "'" out of the various fields so that I can run SQL statements with the data.

    However, it is in the first line of the conform() function that it gives me an error: Run-time Error: '-2147467259(80004005)':File Sharing lock count exceeded. Increase MaxLocksPerFile registry entry.

    reSizeDesc() and reSizeManUID() are functions that decrease the length of these fields for printing purposes.

    Any help would be GREATLY appreciated. Thank you.

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Run-time Error Problem

    Your clearDatabase sub needs to be rewritten.... it's not a good idea to use Recordset.Open for running action queeries like DELETEs. You should bew using the command object instead and using its .Execute method.

    Secondly, you are not closing your connection in the ClearDatabase sub. You're simply setting the connection to nothing. That simply sets the pointer to null, and may or may not actualy close the connection.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Run-time Error Problem

    Agreed.

    Also the time the Wait function takes will vary dramatically by computer, and by the processes running at the time - if you want a proper wait function use a mixture of DoEvents and Sleep in a Do Loop (set to exit after a certain amount of time). The usefulness in this case is hard to see tho, a single DoEvents should do the job.

    Then my function conform() is called to take the "'" out of the various fields so that I can run SQL statements with the data.
    There is no need to do that, as you can use ' in SQL statements (you just need to replace any inside values with two ' characters).

    All you are doing with this is intentionally damaging the data.

    reSizeDesc() and reSizeManUID() are functions that decrease the length of these fields for printing purposes.
    Please tell me they aren't actually modifying data too... you should only be doing that as part of the print process, not with the data in the database.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    200

    Re: Run-time Error Problem

    Thanks guys I got it to work. I found some information on Microsoft's website. If anyone else is getting this error here's the link for the webpage: http://support.microsoft.com/default...-US;815281#kb2

    Thanks again everyone!

    Nenio foriras ĝis ĝi havas instru ni kiu ni devas scii.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width