请确认你的Image列是什么数据类型!
参考下面的代码:
public void GetImage()
{
SqlCommand cmd = new SqlCommand(@"SELECT name, photo FROM Temp", sqlConn);
sqlConn.Open();
SqlDataReader reader = cmd .ExecuteReader();
if (reader.Read())
{
image_filename= (string) reader.GetValue(0);
byte[] image_bytes = (byte[]) reader.GetValue(1);
MemoryStream ms = new MemoryStream(image_bytes);
Bitmap bmap = new Bitmap(ms);
return bmap;
}
byte[] byte_img = Convert.FromBase64String(img64);
if (byte_img.Length > 10 * 1024 * 1000)
{
return ContentHelper.FailureInfo("图片大小超出限制");
}
MemoryStream s = new MemoryStream(byte_img);
Image image = Image.FromStream(s);