I am trying to retrieve an image from a SQL Server database, and I get an exception "parameter not valid"
This is my code for saving:
MemoryStream ms = new MemoryStream();
pictureBox1.Image.Save(ms, ImageFormat.Jpeg);
byte[] b = ms.ToArray();
hospital.run("INSERT INTO emp_eval (id, eval_image) VALUES (" + Convert.ToInt32(textBox24.Text) + ",' + b + ')
And here is my code for restoring:
string ss = "SELECT eval_image FROM emp_eval WHERE id = " + Convert.ToInt32(textBox4.Text) + " ";
SqlCommand command = new SqlCommand(ss, con);
DataTable table = new DataTable();
table.Load(command.ExecuteReader());
byte[] bb = (byte[])(table.Rows[0][0]);
MemoryStream ms = new MemoryStream(bb, 0, Convert.ToInt32(bb.Length));
ms.Seek(0, SeekOrigin.Begin);
Bitmap m = new Bitmap(ms);
pictureBox1.Image = m;
ms.Dispose();