73pixieGirl
Programmer
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!
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!