display image from database

R

Rahul

while writing an image ... i get the following error
my Code
-------------------------------------------------------------------
Dim imgStream As New MemoryStream()
Dim query As String
query = "select Photo from EmployeeMaster where EmpCode='1'"
Dim bImage As Byte() = CType(SQL.ExecuteScalar(query), Byte())

imgStream.Write(bImage, 0, bImage.Length)

Dim bitmap As New Bitmap(imgStream)
Response.ContentType = "image/jpg"
bitmap.Save(Response.OutputStream, ImageFormat.Jpeg)
-------------------------------------------------------------------
Parameter 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.ArgumentException: Parameter is not valid.

Source Error:


Line 333: imgStream.Write(bImage, 0, bImage.Length)
Line 334:
Line 335: Dim bitmap As New Bitmap(imgStream)
Line 336: Image1.ImageUrl = bitmap.ToString
Line 337:


Source File: F:\Send\BCP\DotNet\Alchemy\adEmployee.aspx.vb Line: 335

Stack Trace:


[ArgumentException: Parameter is not valid.]
System.Drawing.Bitmap..ctor(Stream stream) +262
adEmployee.cmbEmployeeName_SelectedIndexChanged(Object sender, EventArgs
e) in F:\Send\BCP\DotNet\Alchemy\adEmployee.aspx.vb:335
System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e)
+96
System.Web.UI.WebControls.DropDownList.RaisePostDataChangedEvent() +145
System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent()
+26
System.Web.UI.Page.RaiseChangedEvents() +165
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3536


Rahul
 
R

Rahul

i got it .... there was a problem in storing an image in the database....
the code to read and display file is right ....

Rahul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top