All,
This is the error I am getting
Server Error in '/' Application.
--------------------------------------------------------------------------------
Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is not
valid.
I have checked myRow("image") and it contains an array of bytes.
Any ideas
Thanks
Msuk
Ray Booysen said:
Are you sure there is a column in the row called "image"?
msuk wrote:
Hi,
I am getting a cast error see below
Dim myArt As DataTable
myArt = dsArtWork.Tables("Art")
Dim myRow As DataRow = myArt.Rows(0)
Dim image As SqlBinary
image = myRow("image") ---> fails here
Response.ContentType = "image/jpeg"
Me.Response.BinaryWrite(image.Value)
Can you please help?
Thanks
:
The example shows you how to get binary data to the response stream.
It is
up to you how to derive the data.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
Hi,
I have a remote component that I call that returns me a Dataset
whereby
the
first field is the image - will this still work using your method?
Thanks
Msuk
:
Provided you have a data reader open on the record and the image
field is
the first in the record, all you need is just:
System.Data.SqlTypes.SqlBinary image = reader.GetSqlBinary(0);
if (!image.IsNull && image.Value.Length > 0)
{
this.Response.ContentType = "image/gif";
this.Response.BinaryWrite (image.Value);
}
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
All,
I have a ADO.NET dataset that contains a jpeg (blob data) and
some
fields
that describe the jpeg. I would like to stream the blob data
straight
to
my
ASP.NET 1.1 webform without first saving to disk and display the
fields
as
labels on the same page is this possible?
Thanks
Msuk