...

View Full Version : Problem with Response.BinaryWrite



dennis_halsey
08-31-2005, 01:59 AM
I am have ASP code that will upload and store a jpg. image in a database in binary form.
this works fine. Displaying out one image at a time on display.asp using Response.BinaryWrite works fine, but when I try to use the image src to display the image (inside a loop), and pass the productID back to the page the write the image, I get no images!

.....here is the code for file.asp which wite out one file at a time and display.asp which displays in on a page

<%
'--------------------------------------------------------------------------------------------------------------------------
'.....here is the contents of File.asp

productID = Request.QueryString("productID")

connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("data\allseasons.mdb")
Set rsX = Server.CreateObject("ADODB.Recordset")
rsX.Open "select [File Data],[Content Type] from products where productID = " & _
productID, connStr, 2, 4

If Not rsX.EOF Then
Response.ContentType = rsX("Content Type")
Response.BinaryWrite rsX("File Data")
End If
'--------------------------------------------------------------------------------------------------------------------------
%>


....here is the contents of display.asp (display the image out.)
<!------------------------------------------------------------------------------------------------------------------------->
<img border="0" src="file.asp?productID=<%=RS("productID")%> width="100" height="100">
<!------------------------------------------------------------------------------------------------------------------------->


The line above is written into a loop

The line above does not seem to pass the product ID to file.asp, or the line below
productID = Request.QueryString("productID")

I can hard code a product number into file.asp like productID=2099 and then display.asp will show the correct image, but it shows this same image for all products when I loop through all the records.
I want it to show the correct image for each record.

Bottom Line:
Can't hard code productID in file.asp, and when i try to read it in dynamically from: <img border="0" src="file.asp?productID=<%=RS("productID")%> width="100" height="100"> I get no images!

Can this be done? It's driving me nuts and It's holding up a good paying Website!

BaldEagle
08-31-2005, 02:45 AM
Not sure this is the problem but might be:

change this:

<img border="0" src="file.asp?productID=<%=RS("productID")%> width="100" height="100">

to this:

<img border="0" src="file.asp?productID=<%=RS("productID")%>" width="100" height="100">

BaldEagle



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum