那位大侠帮助指点一下。
string fullpath = FileUpload1.PostedFile.FileName;
FileStream fs = new FileStream(fullpath, FileMode.Open, FileAccess.Read);
byte[] imagebytes = new byte[fs.Length];
BinaryReader br = new BinaryReader(fs);
imagebytes = br.ReadBytes(Convert.ToInt32(fs.Length));//把所选图片文件的流中的数据读入字节数组 SQL = "Insert into XXXX_Image (PsnImage) Values ('" +imagebytes + "') ";
string fullpath = FileUpload1.PostedFile.FileName;
FileStream fs = new FileStream(fullpath, FileMode.Open, FileAccess.Read);
byte[] imagebytes = new byte[fs.Length];
BinaryReader br = new BinaryReader(fs);
imagebytes = br.ReadBytes(Convert.ToInt32(fs.Length));//把所选图片文件的流中的数据读入字节数组 SQL = "Insert into XXXX_Image (PsnImage) Values ('" +imagebytes + "') ";
解决方案 »
- 关于Tablelayoutpanel的应用
- 在<frameset>中的<frame>不显示?
- asp.net中使用FCKeditor问题
- 关于Sharepoint和Forms认证的兼容性问题
- 回传表单与重定向表单之间的区别是什么?
- 牛人们,进来照顾下菜菜
- 一个邦定的问题
- 我的表里有一个字段(companyname)放很多公司的名称,公司名称有很多重复的.我想在select的时候,把公司名称想同的只取出一条来.请问sql
- Gridview中用sqldatasource作数据源怎样实现多条件查询?
- 怎样在同一个解决方案,不同应用程序中使用一个应用程序里的用户控件
- 求Action一问
- 如何模拟点击别人网站的客户端按钮
还是建议存储为文件.减少数据库体积
string strSql = "insert into Hospital_Employees(EmpNum,EmpName,EmpFingerTmp) values(@EmpNum,@EmpName,@EmpFingerTmp)";
SqlCommand cmd = new SqlCommand(strSql, conn); cmd.Parameters.Add("@EmpFingerTmp", SqlDbType.Binary);
cmd.Parameters["@EmpFingerTmp"].Value = imagebytes;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
{
StringBuilder sb = new StringBuilder();
foreach (byte b in bytes)
{
string sby = Convert.ToString(b, 16); if (sby.Length == 1)
{
sby = "0" + sby;
}
sb.Append(sby);
}
return sb.ToString();
} string fullpath = FileUpload1.PostedFile.FileName;
FileStream fs = new FileStream(fullpath, FileMode.Open, FileAccess.Read);
byte[] imagebytes = new byte[fs.Length];
BinaryReader br = new BinaryReader(fs);
imagebytes = br.ReadBytes(Convert.ToInt32(fs.Length));//把所选图片文件的流中的数据读入字节数组 SQL = "Insert into XXXX_Image (PsnImage) Values (0x" + ConvertBytesToString(imagebytes) + ") ";
至于显示,参考以下链接:
http://blog.csdn.net/lsd123/article/details/3655370