473,387 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 3814
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.