Solved

Error #3704: Operation is not allowed when the object is closed

Posted on 2008-10-01
6
3,267 Views
Last Modified: 2012-05-05
I cannot figure out why I am getting that operation error. can someone please look at this and help me out?

Error #3704: Operation is not allowed when the object is closed
<%@ Language=VBScript %>

<!--#include file="includes/adovbs.inc"-->

<!--#include file="includes/ServerFunction.inc"-->

<!--#include file="Tools/userinfo.inc"-->
 

<%

vMdbFile = Server.MapPath("\virtual\data\EnergySysTC\test.mdb")

	vConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security info=False;Data Source=" & vMdbFile	
 

		'Open Database Connection

		Set Conn = Server.CreateObject("ADODB.Connection")

		Conn.Open vConnStr

		

	

	

		set OpRs = server.createobject("adodb.recordset")
 

%>

<head>

<meta name="HTML_Retention_Review_Frequency" content="">

<meta name="HTML_Last_Reviewed_Date" content="">

<meta name="HTML_Retention_Period_Start_Date" content="9/29/2008">

<meta name="HTML_Initial_Creation_Date" content="9/29/2008 10:43:54 PM">

<meta name="HTML_Record_Title_ID" content="72">

<meta name="HTML_Information_Classification" content="DOW RESTRICTED - For internal use only">

<meta name="HTML_Content_Steward" content="Cannon J u393451">

</head>
 
 

<html>

<body bgcolor="#FFFFFF" vlink=red>
 

<p>
 

<% 

' The first time this page is retrieved and any time it is

' submitted without being completely filled out, the form

' is displayed. If it is submitted and completely filled out

' the form is processed in the Else clause.

If Request("Item")="" Or Request("Description")="" Or _

   Request("Price")="" Or Request("Phone")="" Or _

   Request("Email")="" Or Request("State")="" Then 

%>
 

Please fill in all of these fields below. Be sure to choose 

an appropriate Category for your item.<p>

Be careful when entering a Password and be sure to remember what

you type. You will be required to enter the password later to 

identify you if you need to edit or delete this ad.<p>

When you are finished, click the Place Ad button.<p>
 

<form method="POST" action="placead.asp">

<table>

<tr><td>Item:</td>

<td><input type="text" size="50" name="Item"></td></tr>

<td valign=top>Description:</td>

<td><textarea name="Description" rows="6" cols="50"></textarea></td></tr>

<tr><td>Category:</td>

<td> <select name="Category" size="1">

  <option selected value="VEHICLES">Vehicles</option>

  <option value="COMPUTERS">Computers/Software</option>

  <option value="REALESTATE">Real Estate</option>

  <option value="COLLECTIBLES">Collectibles</option>

  <option value="GENERAL">General Merchandise</option>

</select></td></tr>

<tr><td>Price:</td>

<td><input type="text" size="10" name="Price"> 

</td>

</tr>

<tr><td>Phone</td>

<td><input type="text" size="15" name="Phone"> 

</td>

</tr>

<tr><td>Email:</td>

<td><input type="text" size="50" name="Email"> 

</td>

</tr>

<tr><td>State:</td>

<td><input type="text" size="2" name="State"> 

</td>

</tr>

<tr><td>Password:</td>

<td><input type="password" size="50" name="Password"> 

</td>

</tr>

<tr><td><input type="submit" value="Place Ad"></td></tr>

</table>

</form>
 

<% Else %>

<%

Dim Query, OpRs, Place
 
 
 

On Error Resume Next

%>

<font size=5><b>CATEGORY: <%=Request("Category")%></b></font>

<% 

ShowItem Request("Item"),Request("Description"),_

   Request("Price"),Request("Phone"),Request("Email"),_

   Request("State"),Date
 

		

	

		OpRs.open sql,Conn,adopenkeyset,adlockoptimistic

		

		sql = "Select * FROM tblData WHERE Category='" & _

   Request("Category") & "'"
 

      

OpRs.AddNew

OpRs("Item") = Request("Item")

OpRs("Category") = Request("Category")

OpRs("Description") = Request("Description")

OpRs("Price") = Request("Price")

OpRs("Phone") = Request("Phone")

OpRs("Email") = Request("Email")

OpRs("State") = Request("State")

OpRs("Posted") = Date

OpRs("Password") = Request("Password")

OpRs.Update

If Err.Number = 0 Then %>

<font size=5><i>Your classified ad has been placed.</i></font><p>

<a href="default.asp">Home</a><p>

<% Else %>

There was an error placing your ad.<p>

Error #<%=Err.Number%>: <%=Err.Description%><p>

<% End If %>

<% End If %>
 
 

</body>

</html>

Open in new window

0
Comment
Question by:jlcannon
  • 3
  • 2
6 Comments
 
LVL 82

Assisted Solution

by:hielo
hielo earned 300 total points
ID: 22614305
move line 92:
Dim Query, OpRs, Place


to the top of your page:
<%
Dim Query, OpRs, Place
vMdbFile = Server.MapPath("\virtual\data\EnergySysTC\test.mdb")
....
0
 
LVL 43

Assisted Solution

by:TimCottee
TimCottee earned 150 total points
ID: 22614336
Hello jlcannon,

YOu should swap the lines around so you define the value of the sql statement before you try to open the recordset!

              sql = "Select * FROM tblData WHERE Category='" & _
     Request("Category") & "'"
              OpRs.open sql,Conn,adopenkeyset,adlockoptimistic
             
Regards,

TimCottee
0
 

Author Comment

by:jlcannon
ID: 22614350
thanks, but I moved it and still get same error.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:jlcannon
ID: 22614563
I moved both suggestions and still the same error.
0
 
LVL 82

Assisted Solution

by:hielo
hielo earned 300 total points
ID: 22614859
are you sure the path to your db file is correct? Try this:
<%@ Language=VBScript %>

<!--#include file="includes/adovbs.inc"-->

<!--#include file="includes/ServerFunction.inc"-->

<!--#include file="Tools/userinfo.inc"-->

 

<%

Dim Query, OpRs, Place

On Error Resume Next
 

vMdbFile = Server.MapPath("\virtual\data\EnergySysTC\test.mdb")

Response.Write(vMdbFile)

vConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security info=False;Data Source=" & vMdbFile

 

'Open Database Connection

Set Conn = Server.CreateObject("ADODB.Connection")

Conn.Open vConnStr

                

set OpRs = server.createobject("ADODB.Recordset")

%>

<head>

<meta name="HTML_Retention_Review_Frequency" content="">

<meta name="HTML_Last_Reviewed_Date" content="">

<meta name="HTML_Retention_Period_Start_Date" content="9/29/2008">

<meta name="HTML_Initial_Creation_Date" content="9/29/2008 10:43:54 PM">

<meta name="HTML_Record_Title_ID" content="72">

<meta name="HTML_Information_Classification" content="DOW RESTRICTED - For internal use only">

<meta name="HTML_Content_Steward" content="Cannon J u393451">

</head>

 

 

<html>

<body bgcolor="#FFFFFF" vlink=red>

 

<p>

 

<% 

' The first time this page is retrieved and any time it is

' submitted without being completely filled out, the form

' is displayed. If it is submitted and completely filled out

' the form is processed in the Else clause.

If Request("Item")="" Or Request("Description")="" Or _

   Request("Price")="" Or Request("Phone")="" Or _

   Request("Email")="" Or Request("State")="" Then 

%>

 

Please fill in all of these fields below. Be sure to choose 

an appropriate Category for your item.<p>

Be careful when entering a Password and be sure to remember what

you type. You will be required to enter the password later to 

identify you if you need to edit or delete this ad.<p>

When you are finished, click the Place Ad button.<p>

 

<form method="POST" action="placead.asp">

<table>

<tr><td>Item:</td>

<td><input type="text" size="50" name="Item"></td></tr>

<td valign=top>Description:</td>

<td><textarea name="Description" rows="6" cols="50"></textarea></td></tr>

<tr><td>Category:</td>

<td> <select name="Category" size="1">

  <option selected value="VEHICLES">Vehicles</option>

  <option value="COMPUTERS">Computers/Software</option>

  <option value="REALESTATE">Real Estate</option>

  <option value="COLLECTIBLES">Collectibles</option>

  <option value="GENERAL">General Merchandise</option>

</select></td></tr>

<tr><td>Price:</td>

<td><input type="text" size="10" name="Price"> 

</td>

</tr>

<tr><td>Phone</td>

<td><input type="text" size="15" name="Phone"> 

</td>

</tr>

<tr><td>Email:</td>

<td><input type="text" size="50" name="Email"> 

</td>

</tr>

<tr><td>State:</td>

<td><input type="text" size="2" name="State"> 

</td>

</tr>

<tr><td>Password:</td>

<td><input type="password" size="50" name="Password"> 

</td>

</tr>

<tr><td><input type="submit" value="Place Ad"></td></tr>

</table>

</form>

 

<%

Else 

%>

<font size=5><b>CATEGORY: <%=Request("Category")%></b></font>

<% 

ShowItem Request("Item"),Request("Description"),Request("Price"),Request("Phone"),Request("Email"), Request("State"),Date

sql = "Select * FROM tblData WHERE Category='" & Request("Category") & "'"     

OpRs.open sql,Conn,adopenkeyset,adlockoptimistic

                

OpRs.AddNew

OpRs("Item") = Request("Item")

OpRs("Category") = Request("Category")

OpRs("Description") = Request("Description")

OpRs("Price") = Request("Price")

OpRs("Phone") = Request("Phone")

OpRs("Email") = Request("Email")

OpRs("State") = Request("State")

OpRs("Posted") = Date

OpRs("Password") = Request("Password")

OpRs.Update

If Err.Number = 0 Then %>

<font size=5><i>Your classified ad has been placed.</i></font><p>

<a href="default.asp">Home</a><p>

<% Else %>

There was an error placing your ad.<p>

Error #<%=Err.Number%>: <%=Err.Description%><p>

<% End If %>

<% End If %>

 

 

</body>

</html>

Open in new window

0
 

Accepted Solution

by:
jlcannon earned 0 total points
ID: 22623239
I ended up having to do this:
dim Cat
Cat = Request("Category")
sql = "SELECT * FROM tblData WHERE Category='" & Cat & "'"

making it a variable.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CSS Question.. 3 77
add custom headers to my mail 2 47
Forcing form refresh - classic ASP 7 57
Hide row when retrieving data from database 6 51
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now