this is my code I have tried to retrieve image from db but parameter is not valid on Memory stream and also see many answer about parameter is not valid on stackoverflow but my issue is same
try
{
con = new SqlConnection(cs.DBConn);
con.Open();
// Retrieve BLOB from database into DataSet.
String sql = "Select Image from Users where Username='" + TxtUserName.Text + "' and password='" + TxtPassword.Text + "'";
cmd = new SqlCommand(sql, con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
byte[] b = new byte[0];
b = (Byte[])(dr["Image"]);
MessageBox.Show(b.ToString());
MemoryStream ms = new MemoryStream(b);
pictureBox1.Image = Image.FromStream(ms);
frm.pictureBox2.Image = pictureBox1.Image;
con.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}