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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying image stored in SQL Server 7

Status
Not open for further replies.

davidrobin

Programmer
Aug 17, 2000
50
0
0
GB
I have a database that has binary data in an image field, I want to display this image in an HTML table with other text data on an asp page.

Do any of you actually KNOW how to display the image.

<img src= <%= oRs(&quot;logo&quot;) %> >

also I have tried

Response.BinaryWrite(oRs(&quot;logo&quot;))

and nothing seems to work, either I get a text representation of the binary data or I get the failed to load image place holder.

I have been looking round the web for days on numerous sites, forums but no-one has been able to help as yet.



David
Visual Basic 6 Ent
 
The only way I can see to do this is to write the binary data out to a file and then use the files path etc for the stc of the img element.
 
Hello,
See the article

I have tried their approach
<IMG SRC=&quot;ShowEmployeePicture.asp?EmployeeID=007&quot;>

with proper content-type and binarywrite,
but got only broken image.
May be I'm wrong in a way of inserting the images into the database?
Or my web server cannot serve in such way images?

I'll be glad if someone knows the answer.
D.
 
Just a heads-up for users of Microsoft's Visual Interdev...

If you enable debugging on the project, a META tag is streamed back to your browser before your data:
<!-- METADATA TYPE=&quot;ASP_DEBUG_INFO&quot; -->

This superflous in-band data may interfere with the operation of your (or third-party) ActiveX controls, XML parsers, or anything that depends upon an uncorrupted data stream from the likes of Response.BinaryWrite, etc.

Here's a knowledge base article about it, but it doesn't go far enough - you have to disable _all_ debugging:

Fair warning. This one cost me a few days.

Steven J. Ackerman, Consultant
ACS, Sarasota, FL
steve@acscontrol.com
sja@gte.net
 
In your database store the path where the image was stored.
Even u can store the path of your server.

inthe asp page
<%
set mycon=server.createObject(&quot;Adodb.connection&quot;)
mycon.open &quot;file.DSN&quot;

sql=&quot;select * from table where imgname='&quot;specific image&quot;';&quot;
set rs=mycon.execute sql
%>
<img src=&quot;<%=rs(0)%>&quot; border=1 width=&quot;120&quot; height=&quot;150&quot;>

Regards,
Mathan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top