ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Does destroying the ADO Connection close the database? (https://www.excelbanter.com/excel-programming/272053-re-does-destroying-ado-connection-close-database.html)

Richard Choate

Does destroying the ADO Connection close the database?
 
Yes, that's pretty much it.
Richard Choate

"Tod" wrote in message
...
Here's my newbie ADO question.

My code uses ADO to query an Access database. It's
basically like this:

cn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=" &
ThisWorkbook.Path & "\DatabaseName.mdb;"

Sql = "SELECT * From TableName"

rs.Open Sql, cn

'Do stuff with the recordset

rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing

If I watch Windows Explorer while this code is running, I
see the file being created that says the database is in
use, then see it go away to indicate the database is
closed.

My question is this. Am I doing all I need to do by
closing the connection and destroying the object?

tod




All times are GMT +1. The time now is 10:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com