472,958 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

Improper response.redirect after objConn.execute

21
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!

Expand|Select|Wrap|Line Numbers
  1.     case "delete"
  2.  
  3.         cID = cInt(cleanString(request.QueryString("id")))
  4.  
  5.             set rs = Server.CreateObject("ADODB.Recordset")
  6.             SQL = "SELECT cName FROM class WHERE cID = " & cID
  7.             'response.Write(sql)
  8.             'response.End()
  9.             'Open connection
  10.             rs.Open SQL, objConn
  11.  
  12.             if rs.eof then
  13.  
  14.                 closeRS(rs)
  15.                 closeConn()        
  16.  
  17.                 response.Redirect("admin.asp?page=class" & "&statusMsg=failed") 'THIS LINE IS EXECUTED IF I USE objConn.execute IN THE NEXT SECTION
  18.                 response.End()    
  19.  
  20.             else
  21.  
  22.                 'objConn.open
  23.                 objConn.execute("DELETE FROM class WHERE cID=" & cID)
  24.  
  25.                 closeRS(rs)
  26.                 closeConn()
  27.  
  28.                 response.Redirect("admin.asp?page=class" & "&statusMsg=delOK") 'THIS LINE WON'T EXECUTE IF I USE objConn.execute
  29.                 response.End()
  30.  
  31.             end if
  32.  
  33.     'end case DELETE
Dec 12 '06 #1
6 3787
sashi
1,754 Expert 1GB
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!

Expand|Select|Wrap|Line Numbers
  1.     case "delete"
  2.  
  3.         cID = cInt(cleanString(request.QueryString("id")))
  4.  
  5.             set rs = Server.CreateObject("ADODB.Recordset")
  6.             SQL = "SELECT cName FROM class WHERE cID = " & cID
  7.             'response.Write(sql)
  8.             'response.End()
  9.             'Open connection
  10.             rs.Open SQL, objConn
  11.  
  12.             if rs.eof then
  13.  
  14.                 closeRS(rs)
  15.                 closeConn()        
  16.  
  17.                 response.Redirect("admin.asp?page=class" & "&statusMsg=failed") 'THIS LINE IS EXECUTED IF I USE objConn.execute IN THE NEXT SECTION
  18.                 response.End()    
  19.  
  20.             else
  21.  
  22.                 'objConn.open
  23.                 objConn.execute("DELETE FROM class WHERE cID=" & cID)
  24.  
  25.                 closeRS(rs)
  26.                 closeConn()
  27.  
  28.                 response.Redirect("admin.asp?page=class" & "&statusMsg=delOK") 'THIS LINE WON'T EXECUTE IF I USE objConn.execute
  29.                 response.End()
  30.  
  31.             end if
  32.  
  33.     'end case DELETE
Hi there,

Kindly refer to below modified code segment, hope it works. Good luck & Take care.

Expand|Select|Wrap|Line Numbers
  1.   ..
  2.   ..
  3.   rs.Open SQL, objConn, 1, 3
  4.  
  5.   If rs.RecordCount > 0 Then ' Make sure table is not empty
  6.     If rs.EOF = True Then ' EOF is false
  7.       Response.Redirect "somepage.asp"
  8.       closeRS(rs)
  9.       closeConn()        
  10.     Else ' EOF is true
  11.       objConn.execute("DELETE FROM class WHERE cID=" & cID)
  12.       Response.Redirect "anotherpage.asp"      
  13.       closeRS(rs)
  14.       closeConn()        
  15.     End If
  16.   End If
  17.  
Dec 13 '06 #2
gyung
21
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!
Dec 13 '06 #3
gyung
21
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 >.<
Dec 13 '06 #4
iam_clint
1,208 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1.     case "delete"
  2.  
  3.         cID = cInt(cleanString(request.QueryString("id")))
  4.         set rs = Server.CreateObject("ADODB.Recordset")
  5.         SQL = "SELECT cName FROM class WHERE cID = " & cID
  6.         rs.Open SQL, objConn, 1, 2
  7.         if rs.eof then
  8.             closeRS(rs)
  9.             closeConn()        
  10.             response.Redirect("admin.asp?page=class&statusMsg=failed")
  11.             response.End()    
  12.         else
  13.             'objConn.open
  14.             objConn.execute("DELETE FROM class WHERE cID=" & cID)
  15.             closeRS(rs)
  16.             closeConn()
  17.             response.Redirect("admin.asp?page=class&statusMsg=delOK")
  18.             response.End()
  19.         end if
  20.     'end case DELETE
  21.  
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?
Dec 15 '06 #5
gyung
21
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!
Dec 27 '06 #6
gyung
21
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 :)
Dec 27 '06 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
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...
3
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...
1
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...
10
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....
2
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)....
3
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? ...
4
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...
4
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....
9
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)....
0
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...
0
tracyyun
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...
2
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...
4
NeoPa
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 :...
3
NeoPa
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...
1
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...
0
isladogs
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...
3
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...
0
NeoPa
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.