Solved

How to close ADO Data Control connection?

Posted on 2007-04-03
4
364 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 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…

813 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

9 Experts available now in Live!

Get 1:1 Help Now