"Mark Fitzpatrick" <markfitz@fitzme.com> wrote in message
news:uE3rfaIsDHA.2244@TK2MSFTNGP09.phx.gbl...
> If you're using ASP.Net 1.1, the SqlDataReader class has a method called
> GetBytes. One of the parameters you pass to this function is a byte array,
> which can then be output to the browser in the response.binarywrite
method.
>
> Check out:
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataSqlClientSqlDataReaderClassGetBytesTopic.asp
>
> and
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconobtainingblobvaluesfromdatabase.asp
>
>
> Hope this helps,
> Mark Fitzpatrick
> Microsoft MVP - FrontPage
>
>
> <-> wrote in message news:%23witwCIsDHA.2340@TK2MSFTNGP12.phx.gbl...
> > Hi,
> >
> > I have a SQL Server database table where one of the columns is of type
> > Image.
> > The problem occurs when I try to retrieve images from the table. I'm
using
> > the following C# code:
> >
> >
> > SqlDataReader dr = sqlCommand.ExecuteReader();
> >
> > while (dr.Read())
> >
> > {
> >
> > Response.BinaryWrite(dr["Image"]);
> >
> > }
> >
> > sqlConnection.Close();
> >
> >
> >
> > The error I'm getting is that dr["Image"] is of type object whereas the
> > BinaryWrite method requires a parameter of type Byte[] - How can I
> > convert/cast dr["Image"] into Byte[] ?
> >
> >
> >
> > Also, I have set up a template column on a DataGrid to display images
> using:
> >
> >
> >
> > <asp:TemplateColumn HeaderText="Image">
> >
> > <ItemTemplate>
> >
> > <asp:Image id=Image runat="server" ImageUrl='<%#
> > DataBinder.Eval(Container.DataItem, "Image") %>'>
> >
> > </asp:Image>
> >
> > </ItemTemplate>
> >
> > </asp:TemplateColumn>
> >
> >
> >
> > But can't seem to bind the images to the DataGrid - the images are
reading
> > "System.Byte[]"
> >
> > How can I cast/convert or read the Byte[] array of image binary data
into
> > images?
> >
> >
> >
> > Thanks,
> >
> > Steve.
> >
> >
> >
> >
> >
> >
>
>