Solved

How to close ADO Data Control connection?

Posted on 2007-04-03
4
349 Views
Last Modified: 2013-12-25
Within an Excel VBA application, I'm using the ADO Data Control to populate a DataGrid with data from an Access table.

I set the connection and recordsource properties on opening the file, then set them to empty strings on closing. However once my app. is closed there still exists an Access record-locking icon for the database in Explorer.

I don't seem to be able to close the database; the ADO Data Control doesn't have a connection.close method. How do I do it?  It's even causing a fatal error on Windows shutdown.
0
Comment
Question by:TimHudspith
  • 2
  • 2
4 Comments
 
LVL 29

Expert Comment

by:leonstryker
ID: 18845946
Do not use the ADODC to start with. Ther eis no reason for you to do so.  Instead use ADO directyl

Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset

and so on. Once you create the recordset you bind it to the DataGrid.  At the end:

rs.Close
Set rs = Nothing

conn.Close
Set conn = Nothing

Leon
0
 

Author Comment

by:TimHudspith
ID: 18846314
How do I bind the DataGrid to the recordset?
0
 
LVL 29

Accepted Solution

by:
leonstryker earned 500 total points
ID: 18846332
Once you create a recordset:

Set DataGrid1.DataSource = rst

Leon
0
 

Author Comment

by:TimHudspith
ID: 18846803
Thanks.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

705 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

17 Experts available now in Live!

Get 1:1 Help Now