varbinay和Image一样,Image也是一样传
private void testzp()
{
string fileName = @"D:\JTVMData\2017-04\2017-04-10\20170410125113652-3D-SideView.jpg";
if (!File.Exists(fileName))
{
log.Error(string.Format("照片{0}不存在,无法上传", fileName));
return;
}
byte[] bts = File.ReadAllBytes(fileName);
string strSqlComm = "";
try
{
strSqlComm = "insert into testzp (zp) Values (?)";
sqlCommand.CommandText = strSqlComm;
sqlCommand.Parameters.Add("", OleDbType.VarBinary).Value = bts;
sqlCommand.ExecuteNonQuery();
}
catch (System.Exception ex)
{
ThrowException(string.Format("照片上传失败{0},消息 {1}", fileName, ex.Message));
}
strSqlComm = "select * from testzp where id = 1";
sqlCommand.CommandText = strSqlComm;
OleDbDataReader r = null;
try
{
r = sqlCommand.ExecuteReader();
while (r.Read())
{
MemoryStream steam = new MemoryStream((byte[])r["zp"]);
System.Drawing.Image img = System.Drawing.Image.FromStream(steam, false);
img.Save("I:\\rrr.jpg");
}
r.Close();
}
catch (Exception ex)
{
log.Error(ex.Message);
ThrowException("从服务器获取排队数据异常");
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/36327.html