Can someone help me solve a Microsoft Access 2010 Runtime Error -2147467259 (80004005)


  • Hello,

    I am hoping that someone can help me solve a problem I have run into with some Microsoft Access 2010 code. The code worked in 2007 version but is now having problems in 2010 version producing a runtime error (number stated above) and a message of "Could not use "; file already in use."

    The error is produced by the line of code directly above the comment line below:

    ---code start ---

    Sub getYears()

        Dim strSQL As String
        Dim rs As New ADODB.Recordset
        Dim conn As New ADODB.Connection
        Dim x As Integer
        strSQL = "SELECT DISTINCT YEAR(DandT) FROM [qry_Daily_ElecIntervalData] WHERE Suspect <> Yes;"
        conn.Open ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & CodeDb.Name & ";")
        ' conn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & CodeDb.Name & ";")
        rs.Open strSQL, conn, adOpenStatic, adLockReadOnly

        If Not rs.EOF Then
            ReDim arrYears(1 To rs.RecordCount)
            For x = 1 To rs.RecordCount
                arrYears(x) = rs(0).Value
        End If
        If conn.State <> 0 Then conn.Close
        Set conn = Nothing
    End Sub

    ---code end---

    Any help would be greatly appreciated.


    Friday, May 18, 2012 4:20 PM


  • Hi,

    Based on my research, this issue maybe a Windows NT permissions problem. The account that is accessing the page doesn't have sufficient permissions to lock the database. The account would be either the anonymous account (by default the IUSR_<machinename>) or a specific user account if the page has been secured for authenticated access.

    To resolve this issue, then:

    If the page is meant to be accessed anonymously, give the IUSR_<machinename> account full control to the ASP page, and the folder and files where the database is located. Additionally, if the path to the database is being referenced using UNC (\\Server\Share), ensure that the Share Permissions allow the IUSR_<machinename> account full access. This step applies even if the share is on the local Web server.

    If the page has been secured such that the IUSR_<machinename> can't access the file or database, then ensure that the user's account that is being authenticated has full control to the appropriate folders and files.

    At a minimum, the account being used needs Create, Destroy, Read, Write to work with the .ldb file. Specific permission can be applied to the database to limit access.

    Quote from the link:

    Jaynet Zhang

    TechNet Community Support

    Monday, May 21, 2012 5:46 AM