SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Display Image Stored in SQL Database

    looking for simple sample code to retreive and display image stored in an sql table using asp.net img tag

    thanks

  2. #2
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    You really need two things going on here.

    First, you need to create a http handler to load the images from the database and stream them to the browser with an appropriate content type heading.

    Second, you need to make your other page reference this handler with appropriate parameters to show the image.

  3. #3
    SitePoint Enthusiast forumGuru's Avatar
    Join Date
    Oct 2006
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nniyi
    looking for simple sample code to retreive and display image stored in an sql table using asp.net img tag

    thanks
    Do you really want to store the images as BLOBS in the DB? Why not just store a reference/mapping to the file and then use that instead? Performance can take a serious hit if your DB is cluttered with large objects and it makes a lot of sense to reference the files. It also scales so much better because ultimately you can change the location of where they are stored by simply updating the reference.
    NumaNuma.com - Show us your funny side.

  4. #4
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    A bit OT, but I think alot of people overstate the performance hit of storing binaries in a database vs. on the file system. Especially in web scenarios where the real speed limitation is transfer between browser and server rather than application and directly connected client.

    The argument for scaling by updating references is false as well. First, you should really just store a file name and have the app handle mapping that to the right path. If you need to scale out image serving, you can use alot of techniques supported by most database systems to split the images onto a separate set of spindles without ever touching the application.

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Kuala Lumpur
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alvin Chooi, Malaysia
    Microsoft ASP.NET Enthusiast
    URL: http://alvinzc.blogspot.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •