View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_5_] Bob Phillips[_5_] is offline
external usenet poster
 
Posts: 620
Default Does destroying the ADO Connection close the database?

Tod,

Is something happening here? If you see it open and then go away this seems
to indicate all is okay, so why the question?

Closing the connection will remove the access to the database, and it is a
debatable as to whether you need to destroy the object. Even if you don't,
this is only an instance of the object in memory, it does not allow access.

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"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