Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

display image from database

 
 
Rahul
Guest
Posts: n/a
 
      02-14-2007
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)
+96
System.Web.UI.WebControls.DropDownList.RaisePostDa taChangedEvent() +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


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

Rahul


 
Reply With Quote
 
 
 
 
Thomas Hansen
Guest
Posts: n/a
 
      02-15-2007
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"...
http://ajaxwidgets.com/AllControlsSa...amicImage.aspx

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

..t

--
http://ajaxwidgets.com
Free ASP.NET Ajax Widgets NOW!

 
Reply With Quote
 
 
 
Reply

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 scott93727@gmail.com Computer Information 0 09-27-2012 02:43 AM
DataBase DataBase DataBase DataBase scott93727@gmail.com Computer Information 0 09-26-2012 09:40 AM
Display Image from Database in Image Control chrispragash@hotmail.com ASP .Net 1 10-18-2006 01:48 PM
Display Image from Database in an Image control chrispragash@hotmail.com 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



Advertisments