Solved

How to close database opened by adodc

Posted on 2004-08-28
4
260 Views
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,
Azadeh
0
Comment
Question by:aa_azadeh
4 Comments
 
LVL 1

Expert Comment

by:HolliStt
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?
0
 
LVL 2

Accepted Solution

by:
jags_77 earned 250 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
text1.datafield="YearPublished"


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.....
















0
 
LVL 4

Expert Comment

by:VIkasumit
ID: 11950658
Hi..

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
like

Dim con as new ADODB.connection
con.open

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

con.close

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

VIkasumit
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

914 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

21 Experts available now in Live!

Get 1:1 Help Now