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.