How to close database opened by adodc

Posted on 2004-08-28
Medium Priority
Last Modified: 2013-12-25
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,
Question by:aa_azadeh
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 11919933
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?

Accepted Solution

jags_77 earned 1000 total points
ID: 11921414
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

cn.open [ connection string generated on ADODC, sorrounded in double quotes ]

set rs=new adodb.recordset

rs.open [ 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.....


Expert Comment

ID: 11950658

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


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

719 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