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

EOF BOF problems

Status
Not open for further replies.

73pixieGirl

Programmer
Oct 3, 2006
65
US
Hello!
I'm not very familiar with VBscript so I'm not quite sure what I'm doing wrong. I've compared my code to others that I've found on the internet and it looks right, yet it's not working. In my database I have the fields projectID and pictureName. The picture name field contains the name of an image.
My sql statement calls the pictureName values based on a given projectID value. Since there are 3 records being returned from my sql statement it should print out the 3 image names.
And here's what I have code-wise:
<%

Dim strCon
Dim rs
Dim sSQL

Set rs = Server.CreateObject("ADODB.Recordset")
strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("images.mdb")
sSQL = "Select pictureName from projectPictures where projectID= " & Request.QueryString("pID")
rs.Open sSQL, strCon
%>
<table>
<tr>
<td align="center" valign="bottom" colspan="2" style="padding-top:5;padding-bottom:5">

while not rs.eof
%>
<%=rs("pictureName")%><br>
<%
rs.MoveNext
wend
%>
</td></tr></table>

I get nothing returned to the screen. What's really weird is when I just print out 'Hi' instead of calling the image names from the database, 'Hi' will print out (and I also get the 'Either BOF or EOF is true...' error), but only if I remove the 'not' from my while statement. I've tried adding rs.MoveFirst before my while statement and I get the same BOF/EOF error ('Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.')

Can anyone shed some light on what I'm doing wrong?
Thank you!
 
If projectID is not defined as numeric in projectPictures:
Code:
sSQL = "Select pictureName from projectPictures where projectID=[!]'[/!]" & Request.QueryString("pID") [!]& "'"[/!]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PHV, thanks for the reply. projectID is a number field in the database (I think that's what you meant). I'm using the same query on another page (pulling different values from a different table) and it works fine. Any other ideas?
 
Your problem is that your asp script is malformed.
[tt]
<%

Dim strCon
Dim rs
Dim sSQL

Set rs = Server.CreateObject("ADODB.Recordset")
strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("images.mdb")
sSQL = "Select pictureName from projectPictures where projectID= " & Request.QueryString("pID")
rs.Open sSQL, strCon
%>
<table>
<tr>
[red]<!--[/red]
<td align="center" valign="bottom" colspan="2" style="padding-top:5;padding-bottom:5">
[red]-->[/red]
[red]<%[/red]
while not rs.eof
%>
[blue]<td align="center" valign="bottom" colspan="2" style="padding-top:5;padding-bottom:5">[/blue]
<%=rs("pictureName")%><br>
[blue]</td>[/blue]
<%
rs.MoveNext
wend
%>
<!-- </td> -->
</tr></table>
[/tt]
 
Hi tsuji...thank you for pointing that out! I'm not sure why that would affect the results tho...I don't get any data returned.
 
>I'm not sure why that would affect the results tho...
You must be kidding...

After correct those corrections I posted, try a correct query for testing. The rest is boiled down to that part, if not, it goes to the connection itself.
 
Umm...No, actually I'm not kidding. I changed my SQL query per PH's suggestion and I made the corrections that you posted and I get a page cannot be displayed message. I know the query works b/c it's working on other pages. What about the connection do you think is the problem (do you mean the strCon?)?
 
If you are not joking, you have to learn your profession proper. Malform asp script such as lacking a <% to match %> will lose your job. If you do not think correcting it is a vital step, you are not up to it.
 
Besides I made a quick test page and it performs.
 
Sorry, that was a typo.
Thanks for your help...I'll look elsewhere to find my solution.
 
tsuji: If you are not joking, you have to learn your profession proper. Malform asp script such as lacking a <% to match %> will lose your job. If you do not think correcting it is a vital step, you are not up to it.

Then I am glad you are not in the profession of teaching and/or speaking English.
 
I like to give you fair chance of free expression. I am not going to red-flag. I like it to be left for all to read.
 
Just don't make your compatriots feel ashame of you, CedFoo7.
 
I do not think my compatriots would be ashamed of me pointing out a poor display of grammatical knowledge of the English language. But thank you for the warning.

PS- The proper usage would be "ashamed" not "ashame
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top