Results 1 to 2 of 2

Thread: Image does not display

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2005
    Posts
    182

    Image does not display

    I have the following code and i am trying to display an image from the database.. i have chaecked many times but cannot display that iage..can anybody help me on this..as i have spend hours trying to resolve this issue.. i would appreciate any help.

    System.Data.SqlClient.SqlConnection Con = new System.Data.SqlClient.SqlConnection("Data Source=TANG;Initial Catalog=REM;Integrated Security=True");
    System.String SqlCmd = "SELECT * FROM Image WHERE ID = @ImageID";
    System.Data.SqlClient.SqlCommand SqlCmdObj = new System.Data.SqlClient.SqlCommand( SqlCmd, Con );
    SqlCmdObj.Parameters.Add("@ImageID", System.Data.SqlDbType.VarChar,500).Value = imageID;
    Con.Open();
    System.Data.SqlClient.SqlDataReader SqlReader = SqlCmdObj.ExecuteReader();
    SqlReader.Read();
    System.Web.HttpContext.Current.Response.ContentType = "image/jpeg";
    System.Drawing.Image _image = System.Drawing.Image.FromStream( new System.IO.MemoryStream( (byte[])SqlReader["Data"] ) );
    //System.Drawing.Image _newimage = _image.GetThumbnailImage( 100, 100, null, new System.IntPtr() );
    _image.Save( System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg );
    Con.Close();

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Image does not display

    [code] tags people.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width