Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
DELETE SQL script givies error on close statement?
Old 01-12-2006, 09:41 AM DELETE SQL script givies error on close statement?
ChipJohns's Avatar
I don't know! Do you?

Posts: 488
Name: Chip Johns
Location: Savannah Georgia
Trades: 0
Hello asp friends. I have been busy busy learning asp. Have been too busy to frequent this form enough. In a few weeks things will be settling down and I will have time to search past posts and participate more. In the mean time is a little help possilbe? Please?

I am having trouble with the following error. My instincts are telling me that I do not need to close this connection, or that I have to do it in a different way? This is the code that I have used to close the connection and record set for other scripts that I am running for this (i.e., SELECT and UPDATE SQL Statememts.) The execution of the script works; The proper record is deleted from the database. The only thing is that after execution this page shows the error.

What do I need to do to get the script to finish without giving me this error?

Thanks! Chip

-------------------------------------



Error Type:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.
/admin/deleteitem2.asp, line 28

**My CODE** (Lines just for Reference)
03 -
04 - <%
05 - Dim strTestif
06 - Dim strItem
07 - strTestif = TRIM(Request.FORM("Testif"))
08 - strItem = TRIM(Request.FORM("thisitem"))
09 - %>
10 -
11 - <%
12 - IF strTestif = 0 THEN
13 - %>
**Here is the script that is giving error**
14 - <%
15 - Dim objConnection, objRS, strQuery
16 - Dim strConnection
17 -
18 - set objConnection = Server.CreateObject("ADODB.Connection")
19 - strConnection = "Data Source=catalog1;"
20 - objConnection.Open strConnection
21 - Set objRS = Server.CreateObject("ADODB.Recordset")
22 - Set objRS.ActiveConnection = objConnection
22 -
23 - 'SQL RecordSet
24 - strQuery = "DELETE FROM Cat001 WHERE ItemID = "
25 - strQuery = strQuery & strItem
26 - objRS.Open strQuery
27 -
28 - objRS.Close
29 - objConnection.Close
30 - Set objRS = Nothing
31 - Set objConnection = Nothing
32 - %>
ChipJohns is offline
Reply With Quote
View Public Profile Visit ChipJohns's homepage!
 
 
Register now for full access!
Old 01-15-2006, 10:59 AM
Novice Talker

Posts: 9
Location: Ireland
Trades: 0
Try removing line: 28 - objRS.Close
__________________

Please login or register to view this content. Registration is FREE

---
Please login or register to view this content. Registration is FREE
---
Please login or register to view this content. Registration is FREE
AbbeyIT is offline
Reply With Quote
View Public Profile Visit AbbeyIT's homepage!
 
Old 01-15-2006, 11:04 AM
Novice Talker

Posts: 9
Location: Ireland
Trades: 0
Or you could replace line 28:

if objRS.State = 1 then 'if objRS is open, then close it
objRS.Close
end if
__________________

Please login or register to view this content. Registration is FREE

---
Please login or register to view this content. Registration is FREE
---
Please login or register to view this content. Registration is FREE
AbbeyIT is offline
Reply With Quote
View Public Profile Visit AbbeyIT's homepage!
 
Old 01-15-2006, 01:45 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
a recordset is not required for a DELETE operation so will not be created

remove all references to objRS and use objConnection.execute(strQuery)
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-15-2006, 02:21 PM
ChipJohns's Avatar
I don't know! Do you?

Posts: 488
Name: Chip Johns
Location: Savannah Georgia
Trades: 0
Makes sense Crishirst. If I am not retrieveing
any info from the database, I don't need a
record set to hold it!

I am coming from Cold Fusion, and CF handles
connections to the server completely different.
The connection that I make with asp and the
recordset are actually 2 different things! ..


thanks all !
ChipJohns is offline
Reply With Quote
View Public Profile Visit ChipJohns's homepage!
 
Old 01-26-2006, 10:42 AM
Novice Talker

Posts: 10
Trades: 0
insert , update and delete statements do not require recordsets, so no need to do objRS.close
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
vivald is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to DELETE SQL script givies error on close statement?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24380 seconds with 12 queries