Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script hanging with ID number 2

Status
Not open for further replies.

gtubb

Programmer
Jan 15, 2004
24
GB
Hi

The following script works fine if the variable passed the the URL is text. If I make the variable a number (ID) then the script hangs with no error message. I've tried removing the & "'" but it makes no difference.

Can anyone help?


sql_fields = "SELECT * FROM categories where Category_name = '" & Request.QueryString("folder") & "'"
Set RS = Conn.Execute(sql_fields)

Set rs = Server.CreateObject("ADODB.Recordset")

rs.open sql_fields, Conn, 2, 3

while not(rs.eof)

if rs("category_name") = Request.QueryString("folder") then
rs.delete

rs.movenext
end if
wend
 
You have you movenext command inside an If statement, so if the statement is not true the recordset never moves on.

if rs("category_name") = Request.QueryString("folder") then
rs.delete

rs.movenext
end if

Solution: Move the rs.MoveNext statement outside of this loop.

BDC.
 
BDC

Thanks - I hadn't noticed that I'd moved it - the script has been changed so many times trying to make it work.

Now it doesn't hang, but with a numeric value passed in the URL (blah.asp?ID=46)it won't delete the file.

response.write Request.QueryString("folder") & rs("ID")prints out the ID twice, so am I right to think it's because one is a string and one is an integer?

If so, how do I make the following work:

if rs("ID") = Request.QueryString("folder")then
rs.delete

Gerard
 
Your probably running into a variable type issue, try using cStr() or cInt() on both sides.


Seems silly, I know, but sometimes these variants don't convert correctly for equality statements.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Tarwyn

Forgive my beginners limitations, but where do I try cStr() or cInt() in the script?
 
if CStr(rs("category_name")) = CStr(Request.QueryString("folder")) then

BDC.
 
Thank you both.

if cInt(rs("ID")) = Cint(Request.QueryString("folder")) then

did the trick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top