Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Using IIS ASP to display a blob field in SQL Server 2005

Reply
Thread Tools

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

 
 
None@none.com
Guest
Posts: n/a
 
      08-30-2010
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>
 
Reply With Quote
 
 
 
 
Ziggs
Guest
Posts: n/a
 
      08-30-2010
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, http://www.velocityreviews.com/forums/(E-Mail Removed) 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>

 
Reply With Quote
 
 
 
 
Neil Gould
Guest
Posts: n/a
 
      08-31-2010
(E-Mail Removed) 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







 
Reply With Quote
 
Sylvain Lafontaine
Guest
Posts: n/a
 
      09-01-2010
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)


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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>



 
Reply With Quote
 
Bwig Zomberi
Guest
Posts: n/a
 
      09-02-2010
(E-Mail Removed) 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/micro...0136d1c3e28e0c

--
Bwig Zomberi
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help. Getting a An error has occurred while establishing a connectionto the server. When connecting to SQL Server 2005, this failure may be causedby the fact that under the default settings SQL Server does not allow remote aboutjav.com@gmail.com ASP .Net 0 05-03-2008 12:43 PM
Wohoo! VS.NET 2005/ASP.NET 2.0/SQL Server 2005/BizTalk Server 2006 will launch week of Nov. 7 Juan T. Llibre ASP .Net 0 06-07-2005 05:19 PM
Storing files in a BLOB field via SQL Juergen Gerner Python 7 07-06-2004 11:23 AM
Memory Allocation Error when to fetching BLOB field from MS-SQL server Table Bazil Perl Misc 3 11-30-2003 07:50 PM
Could not allocate enough memory ( Fetch a Blob column from a MS-SQL(7) table. SQL) Steve Perl Misc 4 11-28-2003 06:00 PM



Advertisments