Using IIS ASP to display a blob field in SQL Server 2005

Discussion in 'ASP General' started by None@none.com, Aug 30, 2010.

  1. Guest

    I'm using Windows 2000 Server IIS ASP and I'm attempting to display a
    picture via an vbscript/ASP of a Blob image in SQL Server 2005. Below,
    is part of the code (the important part) that I'm using after reading
    up a bit. Unfortunately, I'm not getting the Blob image in one of our
    Vendor's SQL database to pop up. Instead, I'm getting a box with a
    red X in the middle of it

    Any ideas?

    SQL1 = "SELECT RD.ID, RD.image"
    SQL1 = SQL1 & " WHERE RD.ID = '29'"
    set rs = my_conn.Execute(SQL1)

    <TR>
    <TD bgcolor=<%=FieldColor%> align=center
    colspan=1><B>ID</B></TD>
    <TD bgcolor=<%=FieldColor%> align=center
    colspan=1><B>Picture/B></TD>
    </TR>
    <%if rs.EOF then%>
    <TR>
    <TD bgcolor=<%=InfoField%> align=center
    colspan=10><B>No definition found</B></TD>
    </TR>
    <%
    else
    do until rs.EOF%>
    <TR>
    <TD bgcolor=<%=InfoField%>
    align=center><%=rs("ID")%>&nbsp;</TD>
    <TD bgcolor=<%=InfoField%> align=center><img
    src="<%=rs("image")%>">&nbsp;</TD>
    , Aug 30, 2010
    #1
    1. Advertising

  2. Ziggs Guest

    Small correction. I tried to make the code easier to work with to get
    to the main point. I forgot to add the table in the select statement,
    so here's the corrected statement. Any help is apprecieated.


    SQL1 = "SELECT RD.ID, RD.image from RD"
    "SQL1 = SQL1 & " WHERE RD.ID = '29'"

    On Mon, 30 Aug 2010 00:08:58 -0700, wrote:

    >I'm using Windows 2000 Server IIS ASP and I'm attempting to display a
    >picture via an vbscript/ASP of a Blob image in SQL Server 2005. Below,
    >is part of the code (the important part) that I'm using after reading
    >up a bit. Unfortunately, I'm not getting the Blob image in one of our
    >Vendor's SQL database to pop up. Instead, I'm getting a box with a
    >red X in the middle of it
    >
    >Any ideas?
    >
    >SQL1 = "SELECT RD.ID, RD.image"
    >SQL1 = SQL1 & " WHERE RD.ID = '29'"
    > set rs = my_conn.Execute(SQL1)
    >
    > <TR>
    > <TD bgcolor=<%=FieldColor%> align=center
    >colspan=1><B>ID</B></TD>
    > <TD bgcolor=<%=FieldColor%> align=center
    >colspan=1><B>Picture/B></TD>
    > </TR>
    ><%if rs.EOF then%>
    > <TR>
    > <TD bgcolor=<%=InfoField%> align=center
    >colspan=10><B>No definition found</B></TD>
    > </TR>
    > <%
    > else
    > do until rs.EOF%>
    > <TR>
    > <TD bgcolor=<%=InfoField%>
    >align=center><%=rs("ID")%>&nbsp;</TD>
    > <TD bgcolor=<%=InfoField%> align=center><img
    >src="<%=rs("image")%>">&nbsp;</TD>
    Ziggs, Aug 30, 2010
    #2
    1. Advertising

  3. Neil Gould Guest

    wrote:
    > I'm using Windows 2000 Server IIS ASP and I'm attempting to display a
    > picture via an vbscript/ASP of a Blob image in SQL Server 2005. Below,
    > is part of the code (the important part) that I'm using after reading
    > up a bit. Unfortunately, I'm not getting the Blob image in one of our
    > Vendor's SQL database to pop up. Instead, I'm getting a box with a
    > red X in the middle of it
    >
    > Any ideas?
    >
    > SQL1 = "SELECT RD.ID, RD.image"
    > SQL1 = SQL1 & " WHERE RD.ID = '29'"
    > set rs = my_conn.Execute(SQL1)
    >
    > <TR>
    > <TD bgcolor=<%=FieldColor%> align=center
    > colspan=1><B>ID</B></TD>
    > <TD bgcolor=<%=FieldColor%> align=center
    > colspan=1><B>Picture/B></TD>
    > </TR>
    > <%if rs.EOF then%>
    > <TR>
    > <TD bgcolor=<%=InfoField%> align=center
    > colspan=10><B>No definition found</B></TD>
    > </TR>
    > <%
    > else
    > do until rs.EOF%>
    > <TR>
    > <TD bgcolor=<%=InfoField%>
    > align=center><%=rs("ID")%>&nbsp;</TD>
    > <TD bgcolor=<%=InfoField%> align=center><img
    > src="<%=rs("image")%>">&nbsp;</TD>
    >

    Since you haven't received a reply from those who know more than I, I'll
    chime in with a couple of items...

    Since you are using ...SQL1 & " WHERE RD.ID = '29'" ... I presume that RD.ID
    is a text field? If not, it should probably be ...SQL1 & " WHERE RD.ID = 29"

    If you are getting data from this query, but no pictures (as your post
    implies), I would check the references in the database to verify that the
    links are valid, and point to a location that is accessible from the script.

    And, finally, there are some errors in your HTML, but that may be just the
    way you copied it here and would probably not affect only the images.

    --
    Hope this helps,

    Neil
    Neil Gould, Aug 31, 2010
    #3
  4. You cannot display an image from a Blob field in an ASP page this way;
    however, you say that your code is working for other Vendor's SQL databases
    and that it doesn't work for only one of them; so I'm very confuse.

    My interpretation is that the field "image" is not a blob field but contains
    the name of the file on the hard drive; so it's probably more a question of
    a bad setup for the (virtual) repertory(ies) in IIS than a problem with the
    SQL-Server or the ASP code.

    --
    Sylvain Lafontaine, ing.
    MVP - Access
    Blog/web site: http://coding-paparazzi.sylvainlafontaine.com
    Independent consultant and remote programming for Access and SQL-Server
    (French)


    <> wrote in message
    news:...
    > I'm using Windows 2000 Server IIS ASP and I'm attempting to display a
    > picture via an vbscript/ASP of a Blob image in SQL Server 2005. Below,
    > is part of the code (the important part) that I'm using after reading
    > up a bit. Unfortunately, I'm not getting the Blob image in one of our
    > Vendor's SQL database to pop up. Instead, I'm getting a box with a
    > red X in the middle of it
    >
    > Any ideas?
    >
    > SQL1 = "SELECT RD.ID, RD.image"
    > SQL1 = SQL1 & " WHERE RD.ID = '29'"
    > set rs = my_conn.Execute(SQL1)
    >
    > <TR>
    > <TD bgcolor=<%=FieldColor%> align=center
    > colspan=1><B>ID</B></TD>
    > <TD bgcolor=<%=FieldColor%> align=center
    > colspan=1><B>Picture/B></TD>
    > </TR>
    > <%if rs.EOF then%>
    > <TR>
    > <TD bgcolor=<%=InfoField%> align=center
    > colspan=10><B>No definition found</B></TD>
    > </TR>
    > <%
    > else
    > do until rs.EOF%>
    > <TR>
    > <TD bgcolor=<%=InfoField%>
    > align=center><%=rs("ID")%>&nbsp;</TD>
    > <TD bgcolor=<%=InfoField%> align=center><img
    > src="<%=rs("image")%>">&nbsp;</TD>
    Sylvain Lafontaine, Sep 1, 2010
    #4
  5. Bwig Zomberi Guest

    wrote:
    > I'm using Windows 2000 Server IIS ASP and I'm attempting to display a
    > picture via an vbscript/ASP of a Blob image in SQL Server 2005. Below,
    > is part of the code (the important part) that I'm using after reading
    > up a bit. Unfortunately, I'm not getting the Blob image in one of our
    > Vendor's SQL database to pop up. Instead, I'm getting a box with a
    > red X in the middle of it
    >
    > Any ideas?
    >
    > SQL1 = "SELECT RD.ID, RD.image"
    > SQL1 = SQL1& " WHERE RD.ID = '29'"
    > set rs = my_conn.Execute(SQL1)
    >
    > <TR>
    > <TD bgcolor=<%=FieldColor%> align=center
    > colspan=1><B>ID</B></TD>
    > <TD bgcolor=<%=FieldColor%> align=center
    > colspan=1><B>Picture/B></TD>
    > </TR>
    > <%if rs.EOF then%>
    > <TR>
    > <TD bgcolor=<%=InfoField%> align=center
    > colspan=10><B>No definition found</B></TD>
    > </TR>
    > <%
    > else
    > do until rs.EOF%>
    > <TR>
    > <TD bgcolor=<%=InfoField%>
    > align=center><%=rs("ID")%>&nbsp;</TD>
    > <TD bgcolor=<%=InfoField%> align=center><img
    > src="<%=rs("image")%>">&nbsp;</TD>



    If the db contains a binary blob of the image, you can use it as the
    address (src) of the image tag.

    Use the URL of a separate ASP script in the SRC attribute. In that ASP
    script, retrieve the blob from the database, set the content type
    whatever mime type the image uses (jpeg, gif...), and
    response.binarywrite the contents of the blob. This script should output
    only binary content from the blob, it should not write an spaces or HTML
    blocks.


    Use logic similar to what is presented here
    http://groups.google.com/group/micr...read/thread/67dfa90720edbb2f/9c0136d1c3e28e0c

    --
    Bwig Zomberi
    Bwig Zomberi, Sep 2, 2010
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Juan T. Llibre
    Replies:
    0
    Views:
    455
    Juan T. Llibre
    Jun 7, 2005
  2. Juergen Gerner

    Storing files in a BLOB field via SQL

    Juergen Gerner, Jun 6, 2004, in forum: Python
    Replies:
    7
    Views:
    1,895
    Martin Bless
    Jul 6, 2004
  3. farseer

    SQL Server 2005 + SQL Server Express

    farseer, Aug 7, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    344
    farseer
    Aug 8, 2006
  4. Steve
    Replies:
    4
    Views:
    363
    James Willmore
    Nov 28, 2003
  5. Bazil
    Replies:
    3
    Views:
    327
    William Herrera
    Nov 30, 2003
Loading...

Share This Page