Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to display image blob from database?

Reply
Thread Tools

How to display image blob from database?

 
 
Olav Tollefsen
Guest
Posts: n/a
 
      04-25-2004
How can I display photo images stored in a SQL Server 2000 databases in a
DataList or DataGrid without having to write the images to files first?

Olav


 
Reply With Quote
 
 
 
 
Rick Spiewak
Guest
Posts: n/a
 
      04-25-2004
You should be able to stream them by setting the right mime type in your
output.

"Olav Tollefsen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> How can I display photo images stored in a SQL Server 2000 databases in a
> DataList or DataGrid without having to write the images to files first?
>
> Olav
>
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmlsbCBCb3Jn?=
Guest
Posts: n/a
 
      04-25-2004
Olav

You need a url that returns the image you want, which you bind to each listitem in your datagrid/datalist, e.g. <img src='<%# "GetImage.aspx?src=" + ID %>'

In this example, GetImage.aspx uses the ID you pass and does the i/o to get a byte array from the blob, then returns it in the output stream as a picture, e.g
response.ContentType = "image/jpeg"
response.BinaryWrite(MyByteArray

The other nice thing about using GetImage is that you can very simply modify the image before you return it to the stream, such as add a description or copyright notice onto the picture, return a thumbnail, etc. In that case, you'd create your bitmap from the blob, modify it however, then do bitmap.Save(Response.OutputStream, Imaging.ImageFormat.Jpeg) to output it to the stream

For a great discussion of this and a lot more, check out Esposito's Programming Microsoft ASP.NET from MS Press (pp. 1036-1044)

hth

Bil

----- Olav Tollefsen wrote: ----

How can I display photo images stored in a SQL Server 2000 databases in
DataList or DataGrid without having to write the images to files first

Ola



 
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
Using IIS ASP to display a blob field in SQL Server 2005 None@none.com ASP General 4 09-02-2010 04:51 AM
Display BLOB in crystalreportviewer gsauns ASP .Net 1 02-25-2008 04:52 PM
Display BLOB Image in User Control rh1200la@gmail.com ASP .Net 1 09-15-2007 11:54 PM
How can i display blob into GridView André Despont ASP .Net Datagrid Control 0 12-21-2006 05:46 PM
Outputting in-line image from BLOB in ASP.NET Jonathan ASP .Net 4 12-15-2004 10:34 PM



Advertisments