I am developing a windows application using c#, where the user will save the image and retrieve the image. The image saving is working, but retrieving the image from database to picture box is not working. The code I have written was working 2 days back, but now its not working, Error occurs at runtime as "Parameter is not valid" @ line no.10 Here is my code below :-
- string cnstd = ConfigurationManager.ConnectionStrings["My_ConnectionString"].ConnectionString;
- SqlConnection cone = new SqlConnection(cnstd);
- cone.Open();
- string sql = "Select Pic from Emp_Details";
- SqlCommand command = new SqlCommand(sql, cone);
- byte[] image = (byte[])command.ExecuteScalar();
- cone.Close();
- MemoryStream ms = new MemoryStream(image);
- ms.Seek(0, SeekOrigin.Begin);
- bitmap = (Bitmap)System.Drawing.Image.FromStream(ms);
- pbLogo.Image = bitmap;
Thanks in Advance !!!