BitMap

Aug 6 2008 9:17 AM
Error: Parameter is not valid.

At line no 9 : of this  below code

 con.Open();
        SqlCommand command1 = new SqlCommand("select imgfile from myimages where imgname=@param", con);
        SqlParameter myparam = command1.Parameters.Add("@param", SqlDbType.NVarChar, 30);
        myparam.Value = txtimgname.Text;
        byte[] img = (byte[])command1.ExecuteScalar();
        MemoryStream str = new MemoryStream();
        string s1=str.Write(img, 0, img.Length);       
        Bitmap bit = new Bitmap(s1);
        Response.ContentType = "image/jpeg";//or you can select your imagetype from database or directly write it here
        bit.Save(Response.OutputStream, ImageFormat.Jpeg);
        con.Close();

Answers (1)