Q. DAO close connection causes error!

Q. DAO close connection causes error!

Post by Alistair Colwel » Thu, 30 Jul 1998 04:00:00



When I execute the following code a Dr. Watson error occurs, however
without the connection 'close' line included the data is retrieved
perfectly.  Please can anyone help - it's driving me mad!! Not sure whether
it is my code or perhaps the system setup.

I am trying to connect to a Sybase Database using Excel 97 (VBA)

Sub ODBCDirectTest()

Dim ws As Workspace, rs As Recordset, qt As QueryTable, c As Connection,
ConnectStr As String

   ConnectStr =
"ODBC;DSN=fosdeal;DATABASE=fosdeal;SRVR=DOLP;UID=spp;PWD=welcome"

   Set ws = CreateWorkspace("ODBCDirect", "admin", "", dbUseODBC)
   Set c = ws.OpenConnection("fosdeal", 1, False, ConnectStr)
   Set rs = c.OpenRecordset("SELECT * FROM WK_HOLDINGS")
   Set qt = Sheets("Sheet1").QueryTables.Add(rs, Range("a1"))
   qt.Refresh False
   rs.Close
   c.Close      'This line is where the application crashes!!!!!

End Sub

Thanks in advance.

Alistair.

 
 
 

1. HELP: Closing and ReOpening ADO Connection Causes Unspecified error

When I open, close, and immediately re-open an ADO Connection and RecordSet,
I find that the second attempt to open the connection fails with
"unspecified error." (However if I attempt the same thing from C++ using
ODBC there is no problem.) I have also tried both Excel and Access as the
data source. Is there any way to fix this so I can close and re-open the
same connection without having to wait 15-20 seconds? I encounted this
problem working with Chapter 13 of Active Server Pages 3.0 By Example. I am
running Windows 2000 and Personal Web Server.

Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset
strSQL = "SELECT * FROM Members WHERE LoginName = '"
strSQL = strSQL & LoginID & "'"
cn.ConnectionString = "DSN=MyDataSource"
cn.Open
rs.Open strSQL, cn
rs.Close
cn.Close
... other code ...
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset
strSQL = "SELECT * FROM Members WHERE LoginName = '"
strSQL = strSQL & LoginID & "'"
cn.ConnectionString = "DSN=MyDataSource"
cn.Open ' FAILS HERE UNLESS A LONG DELAY HAS PASSED
rs.Open strSQL, cn
rs.Close
cn.Close

2. Implicit PK

3. Error on Update causing error on Close

4. sp_recompile avoidance

5. Connection::Close causes heap corruption?

6. SQL 'DUMP' From Oracle - How?

7. Connection::Close doesn't actually close connection?

8. Posting Again! Need help w/TUtility!

9. Servlets, Connection Pooling & Closed Connection Error

10. Close causes 3219 error

11. Closing from control box causes error

12. VFP3.0 Newbie Q.: Howto close a form

13. OpenRecordset("select into.... causes DAO.Database error