Help with ADODB.Connection problem...
am 01.03.2005 02:48:29 von jungewumHi,
I am getting an error with the following code.
Error is: ADODB.Connection error '800a0e78' - The operation requested
by the application is not allowed if the object is closed.
Any ideas how the error can be fixed?
Extract of the ASP code below...
<%
dim dbprop, dbconn, dbsessionname
dbprop = "dsn=stock;uid=test;pwd=mem"
dbsessionname = "stock_conn"
monsql = "select count(*) from test_monitor"
' Check database connection
if isobject(session(dbsessionname)) then
reuseDBConnection()
else
doDBConnection()
end if
sub doDBConnection()
set dbconn = server.createobject("ADODB.connection")
' turn on error handling
on error resume next
' reset error
set err.number = 0
' open connection
dbconn.open dbprop
if err.number <> 0 then
Session.Contents.Remove(dbsessionname)
else
set session(dbsessionname) = dbconn
end if
' turn off error handling
on error goto 0
end sub
sub reuseDBConnection()
set dbconn = session(dbsessionname)
' turn on error handling
on error resume next
' reset error
set err.number = 0
' test if connection is valid
rsmon = dbconn.execute(monsql)
''rsmon = null
' if connection is invalid, we create a fresh connection.
if err.number <> 0 then
Session.Contents.Remove(dbsessionname)
doDBConnection()
end if
' turn off error handling
on error goto 0
end sub
%>
Thanks,
June.......