Loding images from sqldb

Last post 05-19-2005 5:39 PM by Mike_123. 4 replies.

Sort Posts:

  • Loding images from sqldb

    09-26-2004, 2:51 PM
    How can I load Images from sql sqrver & show it in a control.
    Note that I want to know whitch control can do it?
    In web app please but not win app.
    thanks.
    Technology is moving faster than you, So try hard.
  • Re: Loding images from sqldb

    09-26-2004, 3:07 PM
    • Member
      27 point Member
    • Sean501
    • Member since 08-11-2004, 10:30 PM
    • California
    • Posts 13
    You can use the <asp:Image> control, or the plain old HTML img tag.

    The trick to binding it to your datasource, is to place the image control inside the ItemTemplate of a Repeater, and bind the Repeater to a list of image URLs which are stored in your database.

    The repeater could look like this sample from "ASP.NET Unleashed".


    <asp:Repeater
    ID="rptImages"
    Runat="Server">

    <ItemTemplate>
    <br>
    <asp:Image
    ImageURL='<%# Container.DataItem( "image_url" ) %>'
    Runat="Server" />
    </ItemTemplate>

    </asp:Repeater>
  • Re: Loding images from sqldb

    09-26-2004, 4:21 PM
    my filed type is image(in sql server)
    I want to load stream of bytes from sqldb to Image control.
    byte[] pictre = -->load from db
    ImageControl. ? = ?
    !!!
    Technology is moving faster than you, So try hard.
  • Re: Loding images from sqldb

    09-29-2004, 12:11 PM
    • Participant
      925 point Participant
    • weakestlink
    • Member since 12-06-2002, 3:02 PM
    • Posts 185
    Only way I know of is using an ashx (or something similar). The thing is: you need an url in order to display an image in the browser. You feed it a unique identifier for the image you want and then serve it up. Security can get funny when you don't want people to access any old picture (by trying identifiers for instance). You'll then need to check access rights in your ashx.

    I have some code, but it's not that general and I don't want to take time to make it that.

    This might be an example:
    http://aspalliance.com/articleViewer.aspx?aId=141
    Uses an aspx page instead of ashx to retrieve the image, but oh well.
    http://msdn.microsoft.com/msdnmag/issues/02/08/WickedCode/
    Shows an example of how to use http handlers (ashx).
    "Computer science is no more about computers than astronomy is about telescopes."



    The late Edsger W. Dijkstra.
  • Re: Loding images from sqldb

    05-19-2005, 5:39 PM
    • Member
      102 point Member
    • Mike_123
    • Member since 04-10-2005, 5:30 AM
    • Posts 21

    You can use BinaryImage from http://asplib.net

    This control supports next way to show a image:

    img.Binary = (byte[]) dr["Image"];

    How I remember they have free version of this control.

     

Page 1 of 1 (5 items)