473,543 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with ADODB.Connectio n problem...

Hi,
I am getting an error with the following code.
Error is: ADODB.Connectio n 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(sessio n(dbsessionname )) then
reuseDBConnecti on()
else
doDBConnection( )
end if

sub doDBConnection( )
set dbconn = server.createob ject("ADODB.con nection")

' 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.Content s.Remove(dbsess ionname)
else
set session(dbsessi onname) = dbconn
end if

' turn off error handling
on error goto 0

end sub

sub reuseDBConnecti on()
set dbconn = session(dbsessi onname)

' 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.Content s.Remove(dbsess ionname)
doDBConnection( )
end if

' turn off error handling
on error goto 0

end sub

%>

Thanks,
June.......
Jul 22 '05 #1
1 7554
June Moore wrote:
Hi,
I am getting an error with the following code.
Error is: ADODB.Connectio n error '800a0e78' - The operation requested
by the application is not allowed if the object is closed.

Any ideas how the error can be fixed?
It would help if you pointed out the line that generates the error. However
....
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(sessio n(dbsessionname )) then
Uh-oh ....
reuseDBConnecti on()
else
doDBConnection( )
end if <snip> sub reuseDBConnecti on()
set dbconn = session(dbsessi onname)

I knew it!!!
BAD. Bad, very bad
http://www.aspfaq.com/show.asp?id=2053

ADO uses OLE DB to connect to data sources. OLE DB has a feature called
Session Pooling which greatly increases performance and minimizes the number
of connections to your databases.

http://msdn.microsoft.com/library/en...l/pooling2.asp
http://support.microsoft.com/?scid=kb;en-us;Q176056
http://support.microsoft.com/default...b;en-us;191572
http://support.microsoft.com/default...b;en-us;324686
Storing your connection in session prevents you from taking advantage of
pooling.
Simplify your code. Use an OLE DB connection string
(http://www.aspfaq.com/show.asp?id=2126). Open your connection immediately
before using it. Close it immediately when finished using it.

<%
dim cn, rs, sSQL
sSQL="select count(*) from test_monitor"
set cn=createobject ("adodb.connect ion")
cn.open "<OLE DB connection string>"
set rs=cn.Execute(s SQL,,1)
if not rs.eof then
Response.Write "test_monit or contains " & rs(0) & "row(s)"
end if
rs.close:set rs=nothing
cn.close:set cn=nothing
%>

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
349
by: Savas Ates | last post by:
i have a website... when a user sign up my site sql="UPDATE users set status=1 WHERE userid = '&username&';" but when a user leave my site i want to adjust status as =0 in my database and when user click another user he must see his status to make this onsession end and on application .end i used codes below.. but it doesnt workk....
1
3625
by: MyndPhlyp | last post by:
I am about to completely lose what is left of my poor mynd! The historical dissertation gets rather verbose, so I hope you can wade through it all. I really need some help on this one or I'm looking at rewriting all my hard work in something else (wasting probably a month or more). (If you want to run and hide now, the error message is "The...
2
4425
by: Jozef | last post by:
Hello, I'm trying to create a central function that runs a connection to an SQL Server database. The connection etc works, but when I try to call it, I get an error saying "Runtime-Error 91: Object variable or with block variable not set". I have pasted the code below. The first section is the function that I'm using, the second function...
1
2023
by: Burton Wilkins | last post by:
Dear Associaties: I asked this question last Friday, and here it is Wednesday and NOBODY has replied. Come on. Help a little. All that I am looking for is 2 lines of code. One of you must know how to do this. Please respond. I'm trying to get the DataLink to work under C++, and I need help. I'm able to make it work under VB and C#,...
0
1529
by: Edwinah63 | last post by:
Hi guys, i am not new to vb6, but a mere tyro in vb.net what i want to do is the following open transaction build an ADODB command object using parameters execute it build another command execute it
1
1955
by: terryspanky | last post by:
----------------------Below are all the codes don't have errors---- The only problem I have is when I Delete, I'ts not deleting the subject that I click. I want to use the above codes to modify the code in "line 168"and in line"393" <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <%Option Explicit%> <% Dim strCourseCode Dim strSubjectCode Dim...
1
1586
by: iskyline | last post by:
hi there, i'm very new to programming with databases ... i'm coding in vbscripting because i'm trying to make a user friendly HTA for the people at work. so the basic process... search recursively for txt files in a given folder - works fine import first text file into a database table1 -works fine --------i'm having a problem...
13
2830
by: Jennifer.Berube | last post by:
well I'm not sure how to go about making my SQL connection string... The code below is what I need to replace with my SQL connection...I just don't know if that code is for DSN or access... I don't want to use DSN just a connection string...help? function GetConnection() const DSN = "membershipdb" const UID = "webuser"
14
2129
by: bcap | last post by:
Hello, I really would apprciate help! =) What I want to do is be able to change the status of mulitple records using a drop down and a checkbox. I have a drop down called "ChangeStatus" with the values to change the status to Pending, Accepted, Declined, Cancelled, Completed.
2
2215
by: cephal0n | last post by:
I have this peroblem thats really bugging me for days, please have a patience to read it and help me find the probplem because I knew I missed it and just cant tell where. I have a table named tblProuctSummary and it has the 6 fields: ItemID - for unique key BuyerA - for those who made the buying BuyerB - for another buyer Manufacturer -for...
0
7355
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7748
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7697
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4900
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3395
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3395
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1830
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.