Results 1 to 2 of 2

Thread: [RESOLVED] Record-locking file not being deleted

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    116

    Resolved [RESOLVED] Record-locking file not being deleted

    Hi,

    I have a small application that connects to an Access database, makes a change in one row, then disconnects. While it's connected, it creates a record-locking file (.ldb), but this doesn't seem to be removed when the user disconnects from the database. The only way to clear it is to open and close the database in Access.

    This is the code (in a module):
    VB Code:
    1. Option Explicit
    2.  
    3. 'The connection object for the database, used throughout the application
    4. Public objConn As ADODB.Connection
    5.  
    6. 'A function to create the database connection
    7. '-Requires a path to the database (strPath)
    8. '-Requires a password for the database (strDatabasePassword)
    9. '-Returns true if connection made
    10. '-Returns false if no connection as database does not exist
    11. Function ConnectToDatabase(ByVal strPath As String, _
    12.   ByVal strDatabasePassword As String) As Boolean
    13.     'Change the pointer to an hourglass
    14.     Screen.MousePointer = vbHourglass
    15.    
    16.     'If the database exists
    17.     If Dir(strPath) <> "" Then
    18.         'Make objConn a new instance of the ADODB.Connection class
    19.         Set objConn = New ADODB.Connection
    20.    
    21.         'Define the connection string for the database
    22.         '-Microsoft Jet 4.0 is the Provider
    23.         '-The database path is passed as an argument to the function
    24.         '-Access mode is not limited to prevent errors
    25.         '-The user connects as Admin to allow any changes to be made
    26.         objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    27.           "Data Source=" & strPath & ";" & _
    28.           "Mode=Share Deny None;" & _
    29.           "User ID=Admin;"
    30.      
    31.         'The password for the database is passed as an argument to the function
    32.         objConn.Properties("Jet OLEDB:Database Password") = strDatabasePassword
    33.  
    34.         'Open the connection object
    35.         objConn.Open
    36.        
    37.         'Connection made
    38.         ConnectToDatabase = True
    39.     Else
    40.         'If the database does not exist, return false
    41.         ConnectToDatabase = False
    42.     End If
    43.    
    44.     'Set the pointer back to normal
    45.     Screen.MousePointer = vbDefault
    46. End Function
    47.  
    48. 'Routine to disconnect from the database
    49. Sub DisconnectFromDatabase()
    50.     'Check that the connection is not already closed
    51.     If objConn.State <> adStateClosed Then
    52.         'Close the connection
    53.         objConn.Close
    54.     End If
    55.    
    56.     'Set it to nothing
    57.     Set objConn = Nothing
    58. End Sub

    Any ideas?

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    116

    Re: Record-locking file not being deleted

    This turned out to be an obvious one!

    My VB code is fine (as you'd expect ) - it turned out I hadn't clicked the 'Modify' box for the folder permissions, so users could create the file, but not delete it.

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