Solved

How to close ADO Data Control connection?

Posted on 2007-04-03
4
390 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
[X]
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
  • 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

623 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