Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > display image from database

Thread Tools

display image from database

Posts: n/a
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(Ob ject sender, EventArgs
e) in F:\Send\BCP\DotNet\Alchemy\adEmployee.aspx.vb:335
System.Web.UI.WebControls.ListControl.OnSelectedIn dexChanged(EventArgs e)
System.Web.UI.WebControls.DropDownList.RaisePostDa taChangedEvent() +145
System.Web.UI.WebControls.DropDownList.System.Web. UI.IPostBackDataHandler.RaisePostDataChangedEvent( )
System.Web.UI.Page.RaiseChangedEvents() +165
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3536


Reply With Quote
Posts: n/a
i got it .... there was a problem in storing an image in the database....
the code to read and display file is right ....


Reply With Quote
Thomas Hansen
Posts: n/a
On Feb 15, 8:13 am, "Rahul" <(E-Mail Removed)> wrote:
> i got it .... there was a problem in storing an image in the database....
> the code to read and display file is right ....

Btw, regarding displaying "dynamic images"...

Click the "Show code" button up left...
Notice the "DynamicImage1_RetrieveImage" event handler method...


Free ASP.NET Ajax Widgets NOW!

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Database Database Database Computer Information 0 09-27-2012 02:43 AM
DataBase DataBase DataBase DataBase Computer Information 0 09-26-2012 09:40 AM
Display Image from Database in Image Control ASP .Net 1 10-18-2006 01:48 PM
Display Image from Database in an Image control ASP .Net Web Services 1 08-25-2005 07:38 PM
HOWTO: display database without refresh web page to query database =?Utf-8?B?U1M=?= ASP .Net 3 05-15-2005 08:22 PM