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!

problem with response.binarywrite

Status
Not open for further replies.

bookouri

IS-IT--Management
Feb 23, 2000
1,464
US
<% Response.Expires = 0
Response.Buffer = TRUE
Response.Clear
Response.ContentType = "image/gif"
Set conn = Server.CreateObject("ADODB.Connection") conn.Open "(your connection string)"
Set rs = conn.Execute("SELECT emp_photo FROM emps WHERE emp_id =1") '
Response.BinaryWrite rs("emp_photo")
Response.End %>

i have code similar to this and it works fine as long as the emp_id in the emps table actually has a photo. How can I display a message "no photo on file" or something like that when i encounter a missing photo?

thanks in advance
 
Test for emp_photo being NULL or empty before the binarywrite

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
 
i tried a couple of ways of doing that and couldnt get it right. I don't do very much html or .asp and always end up hacking away till i get something right when i have to deal with one of these projects. I just havnt had any luck with this one.

 
Code:
with response
  if isnull(rs("emp_photo")) or isempty(rs("emp_photo")) then
      .write("No photo available")
  else
      .binarywrite rs("emp_photo")
  end if
end with


Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
 
I replace my current:

if rs.EOF then response.End
Response.BinaryWrite rs("photo_1")

with
with response
if isnull(rs("photo_1")) or isempty(rs("photo_1")) then
.write("No photo Available")
else
.binarywrite rs("photo_1")
end with

but i dont get a photo or the "no photo available" just the big red x for my graphic

 
Where are you setting the contentType headers?

or are you trying to stream the data into the image tag?



Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top