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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

quick loop

Status
Not open for further replies.

801119

Programmer
Apr 10, 2000
311
0
0
SE
Greetings all...

I'm trying to write a simple loop that will go through an 200 Access database to find a certain record
Code:
    pid = 0
    do until pid = Request.QueryString("id") or rs.EOF
        pid = rs("pid")
        title = rs("title")
        f_name = rs("filename")
        rs.moveNext
    loop

for some reason this code will ONLY stop when rs.EOF and NOT when the correct pid is found.. why is that?

My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
Wouldn't it be easier to change the SQL query to something like:

SELECT * FROM TABLE WHERE pid = " & request.querystring("id")

?
 
Yes, that works. But I also need to know the previous and next pid which is (pid - 1) or (pid + 1)...

the thing that anoys me is that it should stop when it found the correct pid, but it doenst! :/

My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
Somthing makes it always pick the last one... rs.eof, which is really bothering me. I guess it might be something trivial, but i can't see what

My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
try

do while NOT rs.EOF
if pid = Request.QueryString("id") then
pid = rs("pid")
title = rs("title")
f_name = rs("filename")
end if
rs.moveNext
loop






_________________________________________________________
[sub]$str = "sleep is good for you. sleep gives you the energy you need to function";
$Nstr = ereg_replace("sleep","coffee",$str); echo $Nstr;[/sub]
onpnt2.gif
[sup] [/sub]
 
I've tried that to, but this is the only result I'm getting..
Microsoft VBScript runtime error '800a0046'

Permission denied

/dikter.asp, line 83


and line 83:
Set TS = objFSO.OpenTextFile(strFileName, ForReading, Create)

where strFileName = f_name we're retreaving from the database...

My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
so where does this .txt file come into the picture? that should ahve nothing to do with the loop and the recordset dealing with the database.

????

you lost me!
did the syntax I wrote work for the actual first problem you had?

_________________________________________________________
[sub]$str = "sleep is good for you. sleep gives you the energy you need to function";
$Nstr = ereg_replace("sleep","coffee",$str); echo $Nstr;[/sub]
onpnt2.gif
[sup] [/sub]
 
No, it did not work! The key object with the code is to find correct record, then read Title and Filename, then later on to be read the file(filename) and print it onto the page...

My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
Code:
do until rs("pid") = Request.QueryString("id") or rs.EOF
        pid = rs("pid")
        title = rs("title")
        f_name = rs("filename")
        rs.moveNext
    loop

results in

error '80020009' 
/dikter.asp, line 17


My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top