Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 6th, 2008, 08:05 AM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Operation is not allowed when the object is closed

Hello,

this is my code and I have no idea why it is returning an error:
<%
path=server.mappath("mytfasim.mdb")
set con=server.createobject("ADODB.connection")
connString="Driver={Microsoft Access Driver (*.mdb)};Dbq=" & path
sql="delete from tabla1 where f_name='"&request.form("firstname")&"'"
con.execute (sql)
response.redirect "admin.asp"
%>

Error Type:
ADODB.Connection (0x800A0E78)
Operation is not allowed when the object is closed.
/New/delete.asp, line 9

 
Old June 6th, 2008, 12:29 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You forgot to open the Connection first. All you do is define a Connection object and a connection string, but you don't tie the two together and open the connection. Try this:

set con=server.createobject("ADODB.connection")
connString="Driver={Microsoft Access Driver (*.mdb)};Dbq=" & path
sql="delete from tabla1 where f_name='"&request.form("firstname")&"'"

con.Open connString
con.execute (sql)

More info:

http://msdn.microsoft.com/en-us/library/ms807027.aspx

Also, be aware your code is open for SQL Injection. If Request.Form("firstname") contains:

Imar';DELETE FROM tabla1; SELECT FROM tabla1 WHERE 'A' = 'A

you end up with an empty tabla1 table..... ;)

Searching Google for SQL Injection shows you more about this hacker's tool....

Hope this helps,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Operation is not allowed when obejct is closed zazo XSLT 19 July 25th, 2008 01:26 PM
Operation is not allowed when the object is closed kingroon Classic ASP Databases 2 February 5th, 2008 10:29 AM
"OPERATION NOT ALLOWED AFTERRESULT SET IS CLOSED" picky JSP Basics 3 October 12th, 2006 03:26 PM
Operation is not allowed when the object is closed kah Javascript How-To 2 February 16th, 2005 07:20 AM
operation is not allowed when object is closed shoakat Classic ASP Databases 1 November 26th, 2004 12:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.