Solved

How to close ADO Data Control connection?

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…

752 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