Hi, this is my first post but I've been constantly referred to this site when I needed help. Anyway, this time I can't seem to find anything, so here goes.
This is part of my case statement, and I can't figure out why it's having problems. When I use objConn.execute after I check it's not EOF, I will get redirected to the condition that IS EOF, BUT the items is still properly deleted. If I comment out the execute statement, it redirects properly.
Sorry if it's obvious, but I seriously can't see WHY. I have similar code on another page and it works fine.
Thanks in advance! - case "delete"
-
-
cID = cInt(cleanString(request.QueryString("id")))
-
-
set rs = Server.CreateObject("ADODB.Recordset")
-
SQL = "SELECT cName FROM class WHERE cID = " & cID
-
'response.Write(sql)
-
'response.End()
-
'Open connection
-
rs.Open SQL, objConn
-
-
if rs.eof then
-
-
closeRS(rs)
-
closeConn()
-
-
response.Redirect("admin.asp?page=class" & "&statusMsg=failed") 'THIS LINE IS EXECUTED IF I USE objConn.execute IN THE NEXT SECTION
-
response.End()
-
-
else
-
-
'objConn.open
-
objConn.execute("DELETE FROM class WHERE cID=" & cID)
-
-
closeRS(rs)
-
closeConn()
-
-
response.Redirect("admin.asp?page=class" & "&statusMsg=delOK") 'THIS LINE WON'T EXECUTE IF I USE objConn.execute
-
response.End()
-
-
end if
-
-
'end case DELETE
6 3787
Hi, this is my first post but I've been constantly referred to this site when I needed help. Anyway, this time I can't seem to find anything, so here goes.
This is part of my case statement, and I can't figure out why it's having problems. When I use objConn.execute after I check it's not EOF, I will get redirected to the condition that IS EOF, BUT the items is still properly deleted. If I comment out the execute statement, it redirects properly.
Sorry if it's obvious, but I seriously can't see WHY. I have similar code on another page and it works fine.
Thanks in advance! - case "delete"
-
-
cID = cInt(cleanString(request.QueryString("id")))
-
-
set rs = Server.CreateObject("ADODB.Recordset")
-
SQL = "SELECT cName FROM class WHERE cID = " & cID
-
'response.Write(sql)
-
'response.End()
-
'Open connection
-
rs.Open SQL, objConn
-
-
if rs.eof then
-
-
closeRS(rs)
-
closeConn()
-
-
response.Redirect("admin.asp?page=class" & "&statusMsg=failed") 'THIS LINE IS EXECUTED IF I USE objConn.execute IN THE NEXT SECTION
-
response.End()
-
-
else
-
-
'objConn.open
-
objConn.execute("DELETE FROM class WHERE cID=" & cID)
-
-
closeRS(rs)
-
closeConn()
-
-
response.Redirect("admin.asp?page=class" & "&statusMsg=delOK") 'THIS LINE WON'T EXECUTE IF I USE objConn.execute
-
response.End()
-
-
end if
-
-
'end case DELETE
Hi there,
Kindly refer to below modified code segment, hope it works. Good luck & Take care. -
..
-
..
-
rs.Open SQL, objConn, 1, 3
-
-
If rs.RecordCount > 0 Then ' Make sure table is not empty
-
If rs.EOF = True Then ' EOF is false
-
Response.Redirect "somepage.asp"
-
closeRS(rs)
-
closeConn()
-
Else ' EOF is true
-
objConn.execute("DELETE FROM class WHERE cID=" & cID)
-
Response.Redirect "anotherpage.asp"
-
closeRS(rs)
-
closeConn()
-
End If
-
End If
-
Thanks for your reply!
the recordcount property didn't work for me, so I used count(*), which worked fine. It finds a record, but I'm still getting redirected to the wrong place... I think i'll just have to use another way to validate it.
again if I remove the execute, it works fine. I'm guessing it's somehow running the script twice after execution. Thanks again!
Ok it's driving me nuts, I can't validate the entry before deleting properly AND have the successful message. I'll probably be the one managing the site and DB anyway, but from a programming standpoint i'm hung up about it >.<
-
case "delete"
-
-
cID = cInt(cleanString(request.QueryString("id")))
-
set rs = Server.CreateObject("ADODB.Recordset")
-
SQL = "SELECT cName FROM class WHERE cID = " & cID
-
rs.Open SQL, objConn, 1, 2
-
if rs.eof then
-
closeRS(rs)
-
closeConn()
-
response.Redirect("admin.asp?page=class&statusMsg=failed")
-
response.End()
-
else
-
'objConn.open
-
objConn.execute("DELETE FROM class WHERE cID=" & cID)
-
closeRS(rs)
-
closeConn()
-
response.Redirect("admin.asp?page=class&statusMsg=delOK")
-
response.End()
-
end if
-
'end case DELETE
-
heres my modified version for you... hope it works for ya but cId is a number correct is your cleanstring changing the variable to an int?
Hey thanks a lot. I was away for a while so I didn't check this...
Anyway the execute statements are being... executed.. before the if else statements. I found a workaround for that page by not closing the recordsets. I don't know why that works, but it does.
Sometimes validation in if else statements don't work though... Like for my update page for checking dates, my commands are being sent to the SQL server before anything else is evaluated.
Unless I specifically try using something such as response.write(SQL) followed by response.end(), it will complete execute first.
Why is it doing that??
Thanks again!
Ok...
I'm using
If (--) then
%><script>asdf</script><%
end if
so it's being execute along with the objConn.execute
I just put a response.End() behind the script and it works :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: JC |
last post by:
Hi,
I have a simple question regarding the Response.Redirect method. Does the
server stop processing the ASP code as soon as it encounters the Redirect
command? Or does it ever continue to...
|
by: Jed |
last post by:
I have written an HttpHandler which I invoke through an ashx page.
The HttpHandler does various things to process the request, then it is supposed to redirect to a confirmation page.
Everything...
|
by: Vi |
last post by:
Hi,
I have a try block in which I execute a Page.Response.Redirect("myPage.aspx");
This statement always generates the exception: "Thread was being aborted"
and the execution continues in the...
|
by: isaac2004 |
last post by:
hello i am trying to use a response redirect statment to show a message
upon deletion of a record from a database. my database is ran though a
page with a table with a delete option on the side....
|
by: Shawn Convington |
last post by:
Hey,
I am facing a problem which seems srange to me. I have a simple dll
class file i have created in its own projected, so it can be inherited
and used by others (for example security.dll here)....
|
by: Mark Huebner |
last post by:
I have an aspx web page with the following C# code in the page load event.
Can somebody tell me if the Response.Redirect() will cause my tLoadDNN
thread to stop executing before it is finished? ...
|
by: mike.biang |
last post by:
I have an ASP page that is using an XMLHTTP object to request various
pages from my server. I keep a single session throughout the XMLHTTP
requests by bassing the ASPSESSIONID cookie through the...
|
by: nkoier |
last post by:
Hi, I've been going crazy trying to figure out what's wrong with our
Asp.Net 2.0 intranet site.
At the very top of our main page I provide a TextBox and a Button for
submitting Google searches....
|
by: RN1 |
last post by:
When a server encounters the line
Response.Redirect("abcd.asp")
in a ASP script, the server tells the browser that it has to be
redirected to another page (which is abcd.asp, in this case)....
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
| |