日期:2014-05-18  浏览次数:20791 次

C#把图片存入到数据库中,从数据库中提取,数据库已经打开了,数据库中图片的类型为image型
string fullpath = openFileDialog.FileName;//文件路径
  FileStream fs = new FileStream(fullpath, FileMode.Open);
  byte[] imagebytes = new byte[fs.Length];
  BinaryReader br = new BinaryReader(fs);
  imagebytes = br.ReadBytes(Convert.ToInt32(fs.Length));
  string strSql = string.Format("insert into Employee(photo) values(@ImageList)");
  SQLServer.SQLInquiry(strSql);
求高手,详细代码,接下来该如何处理

------解决方案--------------------
//(byte[])row["thePhoto"]
MemoryStream memorystream = null;
Bitmap image = null;
private void convertPhoto(byte [] bs,string empID)
{
 if (bs != null)
 {
memorystream = new MemoryStream(bs);
memorystream.Write(bs, 0, bs.Length);
image = new Bitmap(memorystream);
 }
}