Ask a Question related to ASP Database, Design and Development.
-
Mikael Hellström #1
error when trying to delete object
i get this error when i am trying to close my object after this operation!
What can be wrong?
Regards Mikael
Error Type:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.
My code
<%@ Language=VBScript%>
<!-- #include file ="./connectionStr\conStr.inc" -->
<%
if isEmpty(session("medlemsNr")) then
response.redirect("./somepage.asp")
end if
Response.buffer=true
Response.ExpiresAbsolute = Now()
Response.AddHeader "Cache-Control", "private"
session("last_move")=time()
'--------------------------------------------------------------
Dim objConn ' ADO Recordset Object
Dim objRS ' ADO Connection Object
Dim strSQL
'--------------------------------------------------------------
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString=connectionStr
objConn.Open
'--------------------------------------------------------------
Set objRS = Server.CreateObject("ADODB.Recordset")
strSQL="delete from rosor where id=" & request.QueryString("id")
objRS.Open strSQL, objConn
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
str="./rosor.asp?medlemsNr=" & request.QueryString("medlemsNr")
response.Redirect(str)
%>
Mikael Hellström Guest
-
Can't delete object in Acrobat 7
We moved to OSX recently and we're now using Acrobat 7. In Acrobat 4 or 5, we used to select the Arrow too and we wre able to delete objects from... -
Zaragosa Barbosa : Is there a Fixup to delete an page object?
Jon, Those fixups only remove objects completely outside the trim area or page area. I'm not sure that's what Zaragosa is looking for (I think... -
Is there a Fixup to delete an page object?
I have a preflight action that finds extremely narrow, misplaced images in PDF files (they're generally things where something was supposed to stop... -
Delete stream object
If I use netStream.close command I stop the stream but I don't delete the object that remain in server with the number ID of client and the status... -
Accessing data object on delete command.
Hi guys. I have a datagrind that is bound to a custom collection of a custom object. When a delete button is pressed in the datagrid, I not... -
Ken Schaefer #2
Re: error when trying to delete object
Recordsets are for holding records returned from the server. A DELETE query
does not return any records. Hence your recordset is not open. Hence you
can't call .Close()
All you really need is the connection object:
<%
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open(connectionStr)
strSQL="delete from rosor where id=" & request.QueryString("id")
objConn.Execute(strSQL)
objConn.Close
Set objConn = Nothing
%>
But you are not filtering Request.QueryString for malicious input - you need
to do that to prevent SQL Injection attacks. At the very least:
<%
intID = Request.QueryString("id")
If not isNumeric(intID) or Len(intID) = 0 then
intID = -1
End If
strSQL = "delete from rosor where id=" & intID
%>
Cheers
Ken
"Mikael Hellström" <micke.hellstrom@telia.com> wrote in message
news:ydRgc.56571$mU6.233598@newsb.telia.net...
: i get this error when i am trying to close my object after this operation!
: What can be wrong?
: Regards Mikael
:
: Error Type:
: ADODB.Recordset (0x800A0E78)
: Operation is not allowed when the object is closed.
:
: My code
:
: <%@ Language=VBScript%>
: <!-- #include file ="./connectionStr\conStr.inc" -->
: <%
: if isEmpty(session("medlemsNr")) then
: response.redirect("./somepage.asp")
: end if
:
: Response.buffer=true
: Response.ExpiresAbsolute = Now()
: Response.AddHeader "Cache-Control", "private"
: session("last_move")=time()
: '--------------------------------------------------------------
: Dim objConn ' ADO Recordset Object
: Dim objRS ' ADO Connection Object
: Dim strSQL
: '--------------------------------------------------------------
: Set objConn = Server.CreateObject("ADODB.Connection")
: objConn.ConnectionString=connectionStr
: objConn.Open
: '--------------------------------------------------------------
: Set objRS = Server.CreateObject("ADODB.Recordset")
:
: strSQL="delete from rosor where id=" & request.QueryString("id")
: objRS.Open strSQL, objConn
:
: objRS.Close
: Set objRS = Nothing
:
: objConn.Close
: Set objConn = Nothing
: str="./rosor.asp?medlemsNr=" & request.QueryString("medlemsNr")
:
: response.Redirect(str)
:
: %>
:
:
Ken Schaefer Guest
-
Bob Barrows #3
Re: error when trying to delete object
Please do not multipost. Ken just wasted his time giving you the same answer
I already gave you in the general newsgroup. I doubt he will happy about
this when he finds out, and it may effect his willingness to answer future
questions from you.
This was the correct newsgroup for this question (asp and database related).
There was no need to post it both here and in .general
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"
Bob Barrows Guest
-
Mikael Hellström #4
Re: error when trying to delete object
Hi,
sorry for my crossposting...I was a little desperate. It wont happend again!
Please i have made som changing as u tiped me about. And i want u to look
throu my code here. Send a different one...
Look at my way to handle database conection etc Is this ok or should i do
something
different? This snip is to count click on banners on my site. Thanks for
helping out!
<%
'--------------------------------------------------------------
Response.buffer=true
Response.ExpiresAbsolute = Now()
Response.AddHeader "Cache-Control", "private"
session("last_move")=time()
'--------------------------------------------------------------
Dim objConn ' ADO Recordset Object
Dim objRS ' ADO Connection Object
Dim strSQL
Dim strSQL2
Dim nyKlick
'--------------------------------------------------------------
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString=connectionStr
objConn.Open
'--------------------------------------------------------------
strSQL="SELECT klick,url from banner where bannerId=" &
request.querystring("id")
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn
nyKlick=objRS("klick") +1
redirectStr=objRS("url")
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString=connectionStr
objConn.Open
strSQL2="Update banner set klick=" & nyKlick & " where bannerId=" &
request.querystring("id")
objConn.Execute strSQL2
objConn.Close
Set objConn = Nothing
%>
Regards Mikael
"Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
news:OzsXi3hJEHA.3084@TK2MSFTNGP10.phx.gbl...query> Recordsets are for holding records returned from the server. A DELETEneed> does not return any records. Hence your recordset is not open. Hence you
> can't call .Close()
>
> All you really need is the connection object:
>
> <%
> Set objConn = Server.CreateObject("ADODB.Connection")
> objConn.Open(connectionStr)
>
> strSQL="delete from rosor where id=" & request.QueryString("id")
>
> objConn.Execute(strSQL)
> objConn.Close
> Set objConn = Nothing
> %>
>
> But you are not filtering Request.QueryString for malicious input - youoperation!> to do that to prevent SQL Injection attacks. At the very least:
>
> <%
> intID = Request.QueryString("id")
> If not isNumeric(intID) or Len(intID) = 0 then
> intID = -1
> End If
>
> strSQL = "delete from rosor where id=" & intID
> %>
>
> Cheers
> Ken
>
> "Mikael Hellström" <micke.hellstrom@telia.com> wrote in message
> news:ydRgc.56571$mU6.233598@newsb.telia.net...
> : i get this error when i am trying to close my object after this> : What can be wrong?
> : Regards Mikael
> :
> : Error Type:
> : ADODB.Recordset (0x800A0E78)
> : Operation is not allowed when the object is closed.
> :
> : My code
> :
> : <%@ Language=VBScript%>
> : <!-- #include file ="./connectionStr\conStr.inc" -->
> : <%
> : if isEmpty(session("medlemsNr")) then
> : response.redirect("./somepage.asp")
> : end if
> :
> : Response.buffer=true
> : Response.ExpiresAbsolute = Now()
> : Response.AddHeader "Cache-Control", "private"
> : session("last_move")=time()
> : '--------------------------------------------------------------
> : Dim objConn ' ADO Recordset Object
> : Dim objRS ' ADO Connection Object
> : Dim strSQL
> : '--------------------------------------------------------------
> : Set objConn = Server.CreateObject("ADODB.Connection")
> : objConn.ConnectionString=connectionStr
> : objConn.Open
> : '--------------------------------------------------------------
> : Set objRS = Server.CreateObject("ADODB.Recordset")
> :
> : strSQL="delete from rosor where id=" & request.QueryString("id")
> : objRS.Open strSQL, objConn
> :
> : objRS.Close
> : Set objRS = Nothing
> :
> : objConn.Close
> : Set objConn = Nothing
> : str="./rosor.asp?medlemsNr=" & request.QueryString("medlemsNr")
> :
> : response.Redirect(str)
> :
> : %>
> :
> :
>
>
Mikael Hellström Guest



Reply With Quote

