Results 1 to 4 of 4

Thread: Database connection error

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    3

    Angry Database connection error

    I am using vb.net 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 vb.net 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.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Database connection error

    Suggestion number one would be to error trap the routine.

    It appears that recordset is being closed and then you are trying to do something with it, so I would look at the code before the code that generates the error to see if it is getting closed.

    BTW: What version of VB.NET are you using? It is helpful to select one of the version option buttons when creating a new thread as code that works with 2002/2003 might not work with 2005.

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    3

    Re: Database connection error

    2003.

    How would I trap the error???

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Database connection error

    Quote Originally Posted by lappling
    2003.

    How would I trap the error???
    You wouldn't trap the error. You would fix it. When the application crashes in the debugger it will tell exactly where the issue occurred, then you can look back and see where the connection was closed. You would also do well to stop using ADO and use ADO.NET instead.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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