Pls Help me--------------
I use ASP(C#.NET) and oracle.
When i retrive image from database .it display error message...
System.InvalidC astException: Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'.
my code in the show button is.pls anybody help me ,how to retrive and display the image
protected void btnshow_Click(o bject sender, EventArgs e)
{
DataTable dt = ds.Tables[0];
MemoryStream stream = new MemoryStream();
foreach (DataRow dr in dt.Rows)
{ if (dr[0].ToString() == drpeno.Selected Item.ToString() )
{
byte[] blob = (byte[])dr[1];
stream.Write(bl ob,0,blob.Lengt h);
Bitmap bitm = new Bitmap(stream);
Response.Conten tType = "image/jpeg";
bitm.Save(Respo nse.OutputStrea m,ImageFormat.J peg);
Label1.Text = dr[0].ToString();
// pcimage.ImageUr l = "~/showimage.ashx? id=" + id;
}
}
}
I use ASP(C#.NET) and oracle.
When i retrive image from database .it display error message...
System.InvalidC astException: Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'.
my code in the show button is.pls anybody help me ,how to retrive and display the image
protected void btnshow_Click(o bject sender, EventArgs e)
{
DataTable dt = ds.Tables[0];
MemoryStream stream = new MemoryStream();
foreach (DataRow dr in dt.Rows)
{ if (dr[0].ToString() == drpeno.Selected Item.ToString() )
{
byte[] blob = (byte[])dr[1];
stream.Write(bl ob,0,blob.Lengt h);
Bitmap bitm = new Bitmap(stream);
Response.Conten tType = "image/jpeg";
bitm.Save(Respo nse.OutputStrea m,ImageFormat.J peg);
Label1.Text = dr[0].ToString();
// pcimage.ImageUr l = "~/showimage.ashx? id=" + id;
}
}
}
Comment