• ADODB Connection String (1)

    Author
    Topic
    #369093

    Hello All,

    I posted an “Access Security” question that I have now found to be a ADODB question. I hope no one minds me re-posting the question under a different Subject….

    Running Access 2000, when I go from design mode to view mode on my forms I get the following error:

    Run-time error ‘-2147467259 (80004005)’ The database has been placed in a state by user ‘Admin’ on machine ‘WEIGET1’ that prevents it from being opened or locked.

    What I think is happening is when I open a form in design mode, it locks the database so I can make design changes. Then, when I flip back to view mode I have some VB that is opening a connection to the database using an ADODB connection. Here is the code for the connection:

    Set Conn = New ADODB.Connection
    Conn.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:My DocumentsdatabasesCurrentCopy(Tonya)ProductReleaseControl.mdb;”

    But, when the VB connection executes the database is still locked from when I was in design mode so the connection fails and gives me the runtime error. So, what can I do to be sure that there is no existing connection that locks the database and causes the VB connection to fail? Is there anyway to release a lock on the database from design mode? I need the VB connection because the form has a lot of VB code attached to it that uses the database connection to update tables and things like that, but I also need to be able to switch from design mode to view mode and back again without getting this error.

    Any ideas or suggestions are GREATLY appreciated.

    Regards,

    Amanda

    Viewing 2 reply threads
    Author
    Replies
    • #580251

      What if you close the connection in the on close or on Unload event of the form ?

      • #580275

        I tried that already too (closing the Conn object), but I don’t think the Conn object itself is causing the problem. The database seems to be getting locked while in design mode through it’s own processes, not through the VB connection that I created (cause VB code attached to a form is not executed if you are in design mode). Then, when I flip into view mode, the VB Connection I created gets executed, but because the database is locked (from previously being in design mode) the connection I try to create in VB causes the error because it cannot connect to the database because it is locked. So, how do I close or cancel the lock that was placed on the database while I was in design mode? Is there a setting somewhere that would change how a database is locked when a user has it in design mode?

        Man, I am stumped … thanks for all of the help, and if you (or anyone else for that matter) have any other ideas, PLEASE let me know.

        Regards,
        Amanda

    • #580390

      I’ll let Charlotte or one of the other moderators weigh in on whether this should be linked to the other post, but as I indicated there, I suspect your connection is not being dropped when you switch to design mode. There really isn’t much overhead in ADO in opening a connection, so you can afford to do it each time a specific event on a form needs to manipulate tables.

    • #580398

      There is no point in having two threads running on the same question. Let’s keep the conversation in this thread until a solution is found. You can always change the subject of a post, so you don’t have to stick with the original “Access Security” subject you started with there.

      I’m going to lock this thread, since there are far more replies in the other one.

    Viewing 2 reply threads
    Reply To: ADODB Connection String (1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: