G
Guest
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.
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.