How to display .jpg from Database on webpage

Posted on 2011-10-17
Last Modified: 2012-06-21
The Sql table contains a User row having a 'Logo' column representing a .jpg file.  
The logo column has a datatype of varbinary(MAX).

My webpage references the picture with: <asp:Image ID="imgLogo" runat="server" ImageUrl="CompanyLogo" />

That's where I'm stuck.

The User's Profile is an object called 'myProfile', thus the image can be referred to as myProfile.Logo

In the Page_Load event I need to set the variable CompanyLogo to myProfile.Logo

My overall question is how do I set the CompanyLogo variable to the varbinary(MAX) SQL column's contents.

I'm using Linq to Sql and Database I/O is performed in another tier, so at the time in question, the information is available,
I just don't understand how to implement it.

Question by:jackwebb22002
    LVL 7

    Accepted Solution

    here is a good resource telling it all:
    LVL 7

    Expert Comment

    instead of image data type in the article you can use varbinary(max)

    Author Closing Comment

    Thanks, but i don't need all the Sql IO.
    And as I mentioned, I'm using Linq to Sql
    So I settled on this:

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now