Kanhialal kk

Kanhialal kk

  • NA
  • 234
  • 338.7k

System.ArgumentException was unhandled Message="Parameter is not valid."?

Jun 25 2011 8:10 AM
Hi..
I am working on byte to bitmap image conversion.. so first of all i stored picture in bytes and then stored it in database.. but when I get back picture and fetch it in pictureBox than following exception is occuring ..
System.ArgumentException was unhandled
  Message="Parameter is not valid."


while i have code..

adpt = new SqlDataAdapter("select Picture_pic from Purchase_Material",conn);
            dt = new DataTable();
            adpt.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                foreach(DataRow row in dt.Rows)
                {
                    this.buff = (byte[])row[0];
                }
                MemoryStream stream = new MemoryStream(this.buff, true);
                if (stream.Length == 0L)
                {
                    this.PIC_Lable.Visible = true;
                }
                else
                {
                    stream.Write(this.buff, 0, this.buff.Length);
                    //Bitmap bitmap = new Bitmap((System.IO.Stream)stream);
                    //System.Drawing.Bitmap..ctor(String filename)
                    System.Drawing.Bitmap.
                    this.pictureBox1.Image = bitmap;
                }
            }
please help me...


Answers (10)