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 3814
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: 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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
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...
|
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...
|
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,...
|
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...
| |