日期:2014-05-20  浏览次数:20882 次

怎么将C#中的图片保存到SQL中的image字段中
怎么将C#中一个picturebox控件中的图片保存到SQL的IMAGE字段中.不用保存路径的方法.
还有怎么将IMAGE字段中的图片读出来显示到C#的pictureBox控件中.
能附上具体点的代码吗???

------解决方案--------------------
转为byte类型后存入Image字段。
byte[] imagebytes=null;
FileStream fs=new FileStream(Image_path,FileMode.Open);
BinaryReader br=new BinaryReader(fs);
imagebytes=br.ReadBytes(br.Length);
SqlParameter parInput22=cmd.Parameters.Add( "@员工图片 ",SqlDbType.Image);
parInput22.Direction=ParameterDirection.Input;
cmd.Parameters[ "@员工图片 "].Value=imagebytes;
cmd.ExecuteNonQuery();


数据库中操作图片
How To Read and Write BLOB Data by Using ADO.NET with Visual C# .NET
http://support.microsoft.com/default.aspx?scid=kb;EN-US;309158