From: Alexey Smirnov on
On Feb 4, 6:49 pm, DavidC <dlch...(a)lifetimeinc.com> wrote:
> Thanks. Now I just have to convert your C# to VB.
> --
> David
>
>
>
> "Alexey Smirnov" wrote:
> > On Feb 4, 2:46 pm, DavidC <dlch...(a)lifetimeinc.com> wrote:
> > > Yes, please. I am not familiar with ashx. Thanks.
> > > --
> > > David
>
> > > "Alexey Smirnov" wrote:
> > > > On Feb 3, 11:26 pm, DavidC <dlch...(a)lifetimeinc.com> wrote:
> > > > > I have small images stored in a SQL table as varbinary(max).  How do I load
> > > > > that stored image into an asp.net Image control...or should I use something
> > > > > different?  I only found an ImageUrl property but that refers to a file path.
> > > > >  Any help is appreciated.  Thanks.
> > > > > --
> > > > > David
>
> > > > Use ASHX generic handler
>
> > > > <img src="image.ashx">
>
> > > > Let me know if I should help with the code for ashx
> > > > .- Hide quoted text -
>
> > > - Show quoted text -
>
> > it must be something like this
>
> > [WebService(Namespace = "http://tempuri.org/")]
> > [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
> > public class ImageHandler : IHttpHandler
> > {
> > public void ProcessRequest(HttpContext context)
> > {
> > GetFromDb();
> > }
>
> > private void GetFromDb()
> > {
>
> > ..... your database code here ....
>
> > byte[] content = (byte[])db.ExecuteScalar(sql);
>
> > HttpContext.Current.Response.ContentType = "image/jpeg";
> > HttpContext.Current.Response.BinaryWrite(content);
>
> > }
>
> > public bool IsReusable
> > {
> > get
> > {
> > return false;
> > }
> > }
>
> > }
>
> > Add new ashx to your project and copy the code into it.
>
> > When it works, you will be able to get an image ashttp://yoursite/image..ashx
> > .- Hide quoted text -
>
> - Show quoted text -

Here's more on VB :-)
http://msdn.microsoft.com/en-us/library/ms228090.aspx

Have fun!