Record locking question

Posted on 2006-04-20
Last Modified: 2010-04-23
I am using that is using Access97 tables.  After my program runs several files through the program against the Access97 database I get a cmdrecordset error when stops the program.  When I close my program and restart it it runs ok.  My question is is there a way to catch this error and close and restart the program within my code?   Thanks

The error is:

The connection cannot be used to perform the operation.  It is either closed or invalid in this context.  in GetRecordsetcmd.
Question by:LAppling7775
    LVL 6

    Expert Comment

    are you closing any connections to the database when you have finished with it - ie accessing records, add/edit/delete

    You can use a try catch finally to contain any errors, however best scenario is for a user to not have to restart the program to get it working again. Try and isolate the problem which is causing the cmdrecordset error.

    You can use a try catch to isolate what is going on. Do the following:-


    your code here

    Catch exc As Exception



    Close all connections to database
    LVL 6

    Accepted Solution

    Sorry forgot you need an End Try at end...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Suggested Solutions

    Title # Comments Views Activity
    OleDbDataAdapter.Update 3 32
    How to do in LINQ?? 18 45
    Text in tooltip bound field bridview 3 16
    Merging PDFs with VB.NET 10 11
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now