C#怎么用二进制流存储图片到Sql Server中.?
展开全部
//定义将图片转化为长二进制代码的函数getphoto()
public Byte[] getphoto(string photopath){
string str = photopath;
FileStream file = new FileStream(str, FileMode.Open,
FileAccess.Read);
Byte[] bytBLOBData = new Byte[file.Length];
file.Read(bytBLOBData, 0, bytBLOBData.Length);
file.Close();
return bytBLOBData;
if (this.pictureBox1.Image != null){
sql1 = sql1 + ",Photo";
public Byte[] getphoto(string photopath){
string str = photopath;
FileStream file = new FileStream(str, FileMode.Open,
FileAccess.Read);
Byte[] bytBLOBData = new Byte[file.Length];
file.Read(bytBLOBData, 0, bytBLOBData.Length);
file.Close();
return bytBLOBData;
if (this.pictureBox1.Image != null){
sql1 = sql1 + ",Photo";
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询