display image from database

Discussion in 'ASP .Net' started by Rahul, Feb 14, 2007.

  1. Rahul

    Rahul Guest

    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
     
    Rahul, Feb 14, 2007
    #1
    1. Advertising

  2. Rahul

    Rahul Guest

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

    Rahul
     
    Rahul, Feb 15, 2007
    #2
    1. Advertising

  3. On Feb 15, 8:13 am, "Rahul" <> 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/AllControlsSamples/DynamicImage.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!
     
    Thomas Hansen, Feb 15, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sandi
    Replies:
    3
    Views:
    1,768
    Natty Gur
    Nov 6, 2003
  2. Olav Tollefsen

    How to display image blob from database?

    Olav Tollefsen, Apr 25, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,389
    =?Utf-8?B?QmlsbCBCb3Jn?=
    Apr 25, 2004
  3. =?Utf-8?B?U1M=?=
    Replies:
    3
    Views:
    3,843
    Juan T. Llibre
    May 15, 2005
  4. Replies:
    1
    Views:
    1,264
    Metalore
    Oct 18, 2006
  5. Replies:
    1
    Views:
    223
Loading...

Share This Page