<%@Language=VBScript%> <% Option Explicit %> <% ' Setup HTTP Header Information so that the browser interprets the returned data as an image 'on error resume next Response.Buffer = TRUE 'Response.ContentType = "image/jpeg" Dim imageId Dim Conn Dim SQL DIM RS DIM picOrder imageId = Request.QueryString("ImageId") picOrder = Request.QueryString("PicOrder") Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "Driver={SQL Server};Server=sqlprod.sys-server.net;Database=REShowCase;Uid=re_user;Pwd=re_login;" SQL = "SELECT Picture FROM tblListingImages WHERE ImageType=1 AND PicOrder=" & picOrder & " AND ListingId = " & imageId SET RS=Conn.execute(SQL) IF (Rs.EOF AND Rs.BOF) then SQL = "SELECT Picture FROM tblListingImages WHERE ImageType=2 AND PicOrder=" & picOrder & " AND ListingId = " & imageId SET RS=Conn.execute(SQL) end if IF NOT (Rs.EOF AND Rs.BOF) then ' Make sure that the image field contains some data if Rs("Picture").ActualSize > 0 then ' Write the Data back to client. Because MIME type is set to image/jpeg the browser ' will automatically render as an image without needing controls, applets etc. Response.ContentType = "image/jpeg" Response.BinaryWrite RS("Picture").GetChunk(RS("Picture").ActualSize) else Response.BinaryWrite ReadBinaryFile(Server.MapPath("images/spacer.gif")) end if else Response.BinaryWrite ReadBinaryFile(Server.MapPath("images/spacer.gif")) end if rs.close set rs=nothing conn.close set conn=nothing Response.End Function ReadBinaryFile(FileName) Const adTypeBinary = 1 'Create Stream object Dim BinaryStream Set BinaryStream = CreateObject("ADODB.Stream") 'Specify stream type - we want To get binary data. BinaryStream.Type = adTypeBinary 'Open the stream BinaryStream.Open 'Load the file data from disk To stream object BinaryStream.LoadFromFile FileName 'Open the stream And get binary data from the object ReadBinaryFile = BinaryStream.Read End Function %>