HELP: Closing and ReOpening ADO Connection Causes Unspecified error

HELP: Closing and ReOpening ADO Connection Causes Unspecified error

Post by Tad Wood » Thu, 29 Mar 2001 03:00:05



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

 
 
 

HELP: Closing and ReOpening ADO Connection Causes Unspecified error

Post by Wole Kolawol » Thu, 05 Apr 2001 01:06:24


Try setting cn and rs to Nothing before doing the second
CreatObject("ADODB.Connection")

BR,
Wole.


Quote:> 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


 
 
 

1. Closing connection and then reopening

In order to compact a database, the data environment connections must be
closed.  However, when I reopen the connection any bound controls are no
longer bound to their commands.  Does anyone have any suggestions on how
to handle this?

I can write code in the form load event of each form to manually open
the recordsets that the controls are bound to, but this seems uneccesary
since if I don't close the connection everything is OK.

Matt Ridge
VB6 / Access '97

2. weird cursor error with dba_*

3. -2147467259 Unspecified error using ADO 2.5 connection object

4. Backup Process is Ingres

5. Unspecified error on ADO connection

6. 16 Bit Open Client and Windows 98

7. Q. DAO close connection causes error!

8. View Related Simple Question !

9. ADO Connection from C++ Unspecified Error

10. Unspecified error on ADO connection

11. HELP: VB 5.0 ODBC Sybase close reopen

12. About ADO and DE Connections reopening

13. ReOpen ADO Recordset with a current Connection