我在程序里读取sql server 2005的image字段,显示在一个PictureBox里,用户可以修改该PictureBox里的图片,然后保存。下面是我的代码:
读取图片并显示在PictureBox里,这段代码执行没有问题:byte[] b = (byte[])dt.Rows[0]["Photo"];  //dt为查询出的DataTable,Photo为表里的image字段名称
MemoryStream s = new MemoryStream(b, true);
s.Write(b,0,b.Length);
Image a = new Bitmap(s);Bitmap bit = new Bitmap(picPhoto.Width, picPhoto.Height);
Graphics g = Graphics.FromImage(bit);//从指定的 Image 创建新的 Graphics(绘图)。
g.DrawImage(a, new Rectangle(0, 0, bit.Width, bit.Height), new Rectangle(0, 0, a.Width, a.Height), GraphicsUnit.Pixel);picPhoto.Image = bit;  //picPhoto为pictureBox 控件下面是保存修改后的PictureBox里的图片到数据库的代码,这段代码出错,系统提示“将参数值从 Int32 转换到 Byte[] 失败”。:MemoryStream ms = new MemoryStream();
picPhoto.Image.Save("a.jpg");
FileStream fs = new FileStream("a.jpg", FileMode.Open, FileAccess.Read);
BinaryReader binaryReader = new BinaryReader(fs);
byte[] img = binaryReader.ReadBytes((int)fs.Length);
binaryReader.Close();
fs.Close();
File.Delete("a.jpg");
info.Photo = img;     //info为定义的实体类
请问这是什么原因啊?