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