Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

campbemr

Technical User
Aug 16, 2001
19
US
I got this application from a book and when I try and run it I get an error. Below is the source for the placead.asp. This is the one I get the error on. The link for the website is:

<% Option Explicit %>
<!-- #include file=&quot;common/adovbs.inc&quot; -->
<html>
<body bgcolor=&quot;#FFFFFF&quot; vlink=red>

<!-- #include file=&quot;header.inc&quot; --><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(&quot;Item&quot;)=&quot;&quot; Or Request(&quot;Description&quot;)=&quot;&quot; Or _
Request(&quot;Price&quot;)=&quot;&quot; Or Request(&quot;Phone&quot;)=&quot;&quot; Or _
Request(&quot;Email&quot;)=&quot;&quot; Or Request(&quot;State&quot;)=&quot;&quot; Then
%>
<% ShowHeader &quot;Place A New Ad&quot; %>
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=&quot;POST&quot; action=&quot;placead.asp&quot;>
<table>
<tr><td>Item:</td>
<td><input type=&quot;text&quot; size=&quot;50&quot; name=&quot;Item&quot;></td></tr>
<td valign=top>Description:</td>
<td><textarea name=&quot;Description&quot; rows=&quot;6&quot; cols=&quot;50&quot;></textarea></td></tr>
<tr><td>Category:</td>
<td> <select name=&quot;Category&quot; size=&quot;1&quot;>
<option selected value=&quot;VEHICLES&quot;>Vehicles</option>
<option value=&quot;COMPUTERS&quot;>Computers/Software</option>
<option value=&quot;REALESTATE&quot;>Real Estate</option>
<option value=&quot;COLLECTIBLES&quot;>Collectibles</option>
<option value=&quot;GENERAL&quot;>General Merchandise</option>
</select></td></tr>
<tr><td>Price:</td>
<td><input type=&quot;text&quot; size=&quot;10&quot; name=&quot;Price&quot;>
</td>
</tr>
<tr><td>Phone</td>
<td><input type=&quot;text&quot; size=&quot;15&quot; name=&quot;Phone&quot;>
</td>
</tr>
<tr><td>Email:</td>
<td><input type=&quot;text&quot; size=&quot;50&quot; name=&quot;Email&quot;>
</td>
</tr>
<tr><td>State:</td>
<td><input type=&quot;text&quot; size=&quot;2&quot; name=&quot;State&quot;>
</td>
</tr>
<tr><td>Password:</td>
<td><input type=&quot;password&quot; size=&quot;50&quot; name=&quot;Password&quot;>
</td>
</tr>
<tr><td><input type=&quot;submit&quot; value=&quot;Place Ad&quot;></td></tr>
</table>
</form>

<% Else %>
<%
Dim Query, Connect, Classifieds, Place

ShowHeader &quot;Place A New Ad&quot;

On Error Resume Next
%>
<font size=5><b>CATEGORY: <%=Request(&quot;Category&quot;)%></b></font>
<%
ShowItem Request(&quot;Item&quot;),Request(&quot;Description&quot;),_
Request(&quot;Price&quot;),Request(&quot;Phone&quot;),Request(&quot;Email&quot;),_
Request(&quot;State&quot;),Date

Set connect = Server.CreateObject(&quot;ADODB.Connection&quot;)
'DSN-less connection
'Database must be named classified.mdb
dsnname = &quot;DRIVER=Microsoft Access Driver (*.mdb);DBQ=&quot;
dsnname = dsnname & Server.MapPath(&quot;db/classified.mdb&quot;)
connect.Open dsnname


Set Classifieds = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Classifieds.Open _
&quot;SELECT * FROM Items WHERE Category='&quot; & _
Request(&quot;Category&quot;) & &quot;'&quot;,_
Connect,adOpenDynamic,adLockOptimistic
Classifieds.AddNew
Classifieds(&quot;Item&quot;) = Request(&quot;Item&quot;)
Classifieds(&quot;Category&quot;) = Request(&quot;Category&quot;)
Classifieds(&quot;Description&quot;) = Request(&quot;Description&quot;)
Classifieds(&quot;Price&quot;) = Request(&quot;Price&quot;)
Classifieds(&quot;Phone&quot;) = Request(&quot;Phone&quot;)
Classifieds(&quot;Email&quot;) = Request(&quot;Email&quot;)
Classifieds(&quot;State&quot;) = Request(&quot;State&quot;)
Classifieds(&quot;Posted&quot;) = Date
Classifieds(&quot;Password&quot;) = Request(&quot;Password&quot;)
Classifieds.Update
If Err.Number = 0 Then %>
<font size=5><i>Your classified ad has been placed.</i></font><p>
<a href=&quot;default.asp&quot;>Home</a><p>
<% Else %>
There was an error placing your ad.<p>
Error #<%=Err.Number%>: <%=Err.Description%><p>
<% End If %>
<% End If %>


</body>
</html>
 
Hi, I think the error is in the &quot;connect.Open dsnname&quot; statement. You have not got a SQL statement querying your database so the file does not open hence your error. I think you may have missed a few lines transcribing the code because I see you have a dim statement a few lines earlier &quot;Dim Query, Connect, Classifieds, Place&quot; the variable Query looks like it should be the SQL statement you are passing to the database.....but there is not any other reference to that variable in any of your code...

it should look something like :

query=&quot;select * from tablename&quot;
connect.open query,dsnname


there appears to be another problem in that I cannot figure out what the whole section after the &quot;Dim Query, Connect, Classifieds, Place&quot; until &quot;connect.open dsnname&quot; is for anyway...you are making a connection but not displaying any data from the database..did you maybe insert the middle of a different page into this page....anyway...the thing is a bit of a mess...
Maybe ifg you check it and clarify what it is and it is supposed to do.....



bassguy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top