I'm having a memory exception because I only read my table's image column without specifying that it's a byte. How can I do this?
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
if (rdr.HasRows)
{
while (rdr.Read())
{
FileStream fs = new FileStream("image.bmp", FileMode.Create);
byte[] picbyte = (byte[])rdr["userimage"];
fs.Write(picbyte, 0, picbyte.Length);
displaypb.Image = Image.FromFile("image.bmp");
fs.Close();
fs = null;
}
}
This is where I think i'm having problems. First of all it cannot be converted to a string. I need to set it to bytes, at least that's what I think. Maybe .getbytes, but how?
byte[] picbyte = (byte[])rdr["userimage"];