Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • Last Modified:

How to close database opened by adodc

Dear all,

I used adodc to navigate through a database but when I close the program , the lock file which is created at the time of opening database won't be deleted and it would remain as the connection to database isn't closed. I tested different codes to close the database but it wasn't successful such as adodc1.recordset.close.

Thank you,
1 Solution
Would be good to get code for opening your db. Something is different to normal. I never got that problem.

You can unload adodc1 object and set to nothing, who about that?
When accessing and navigating a DB the best option is via code only. My suggestion is this:

1.- Connect to your DB as you normally do with ADODC.
2.- Copy the connectionstring generated
3.- Set project-references-MS ActiveX data objects 2.0 ( minimum )
4.- Set the instances in general declarations:

dim cn as adodb.connection
dim rs as adodb.recordset

5.- Use 'em:

set cn=new adodb.connection [ connection string generated on ADODC, sorrounded in double quotes ]

set rs=new adodb.recordset [ desired query, such as " select * from books" ],cn

6.- Set bound controls:

Set text1.datasource=rs

7.- Destroy instances when not in use:
set cn=nothing
set rs=nothing

8.- enjoy the no-more-problems-with-objects DB connection....

Hope this can be useful.....


I see the code above and I would like to add a single piece of code...
In any connection you have a option of close

Dim con as new ADODB.connection

similarly we have
' The line below closes the connection explicility and right way to do


'Than set to Nothing if you want to free resources
set con=nothing

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now