How to CLOSE an ADODC connection

webbone
01-08-2004, 11:40 AM
Hi all!

I'm sure this is a really foolish question, but I have searched the help and looked in several books and cannot find HOW to do this.

I have a form with an ADO Data Control and a DataGrid control - the DataGrid conrol DataSource is the ADODC and the ADODC gets connected to various tables in a few different databases depending upon the current context.

Is there a way to get the ADODC connection to COMPLETELY disconnect from the database? The databases are all MSAccess .mdb files and whenever the ADODC is connected there is the associated .ldb lock file present and I can't overwrite the file with any utilities.

I have tried ADODC1.Recordset.Close (which succeeds) but this does not remove the connection to the database.

Thanks for help with what is probably obvious if I only looked in the correct place.

Dennis DVR
01-08-2004, 11:44 AM
Hi all!

I'm sure this is a really foolish question, but I have searched the help and looked in several books and cannot find HOW to do this.

I have a form with an ADO Data Control and a DataGrid control - the DataGrid conrol DataSource is the ADODC and the ADODC gets connected to various tables in a few different databases depending upon the current context.

Is there a way to get the ADODC connection to COMPLETELY disconnect from the database? The databases are all MSAccess .mdb files and whenever the ADODC is connected there is the associated .ldb lock file present and I can't overwrite the file with any utilities.

I have tried ADODC1.Recordset.Close (which succeeds) but this does not remove the connection to the database.

Thanks for help with what is probably obvious if I only looked in the correct place.

did you try setting the recordset property to nothing? i.e

Set ADODC1.Recordset = Nothing

cmeares
01-08-2004, 11:51 AM
Hi all!

I'm sure this is a really foolish question, but I have searched the help and looked in several books and cannot find HOW to do this.

I have a form with an ADO Data Control and a DataGrid control - the DataGrid conrol DataSource is the ADODC and the ADODC gets connected to various tables in a few different databases depending upon the current context.

Is there a way to get the ADODC connection to COMPLETELY disconnect from the database? The databases are all MSAccess .mdb files and whenever the ADODC is connected there is the associated .ldb lock file present and I can't overwrite the file with any utilities.

I have tried ADODC1.Recordset.Close (which succeeds) but this does not remove the connection to the database.

Thanks for help with what is probably obvious if I only looked in the correct place.

did you try setting the recordset property to nothing? i.e

Set ADODC1.Recordset = Nothing



Public Sub KillADOConn()
MyRecSet.Close
MyConn.Close
Set MyConn = Nothing
Set MyRecSet = Nothing
End Sub


I use this code to close my connection to the DB and Recodset. I run this on my Form_Unload event.

Dennis DVR
01-08-2004, 12:06 PM
he's using a ado datacontrol not an ado object

webbone
01-08-2004, 12:11 PM
Set ADODC1.Recordset = Nothing
[/VB]

Yes, I have tried that with the following result:

A message box appears with the title "Installation" (this was the table in the database the ADODC had been pointing to) saying:

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

This does NOT generate a trappable error or I would have just "handled" it for the moment until I find the elegant solution! *L*

You cannot set ADODC.RecordSource to NOTHING so I'm unclear as to where to go from here.

Thanks for the quick replies - any other suggestions?

Dennis DVR
01-08-2004, 12:35 PM
it's not the recordsource it's the recordset try to look at the example again. It work fine on my pc.

Dennis DVR
01-08-2004, 12:41 PM
it's not the recordsource it's the recordset try to look at the example again. It work fine on my pc.

are you sure you're using ado datacontrol?

webbone
01-08-2004, 12:49 PM
I DID use recordset -


Set Adodc1.Recordset = Nothing


Somewhere between that instruction and the next is when I get the messagebox mentioned previously. Since it references "Installation" which was the RecordSource for the ADODC, I was wondering if I have to "de-reference" that first so to speak.

I have a feeling that this is an internal thing in the ADO Data Control (I'm assuming it creates it's own ADO connection internally) - and that I cannot kill internal stuff in the control short of unloading it (which isn't possible in my context).

I have also tried setting the DataGrid control DataSource property to Nothing PRIOR to setting the ADODC.Recordset to Nothing - I get the same message box so I would assume the problem is strictly in the ADO Data Control somehow.

Doing this Set DOES successfully release the lock on the file in question and allows me to do the file copying required = I am just trying to make this look clean to the user.

webbone
01-08-2004, 12:50 PM
are you sure you're using ado datacontrol?

Yes - just double checked since this is inherited code - good thought though! It is the Microsoft ADO Data Control Version 6.0 (SP4) according to the About dialog.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum