从mysql读取图片_如何从sql数据库内读取图片
privatevoidSHOW(){MemoryStreamstream=newMemoryStream();byte[]buffByte=null;stringsqlstr="selectRefFinImagefromRefTablewhereRefId=5";//我要規定死讀入第五張圖片SqlConnectio...
private void SHOW()
{
MemoryStream stream = new MemoryStream();
byte[] buffByte = null;
string sqlstr = "select RefFinImage from RefTable where RefId=5";
//我要規定死讀入第五張圖片
SqlConnection con = new DataBase().OpenCon();
SqlCommand cmd = new SqlCommand(sqlstr, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
buffByte = ((byte[])dr[0]);
}
dr.Close();
con.Close();
//將圖像的字節數組放入內存流
stream = new MemoryStream(buffByte);
//通過流對象建立Bitmap
Bitmap map = new Bitmap(stream);
//但是 的到了 Bitmap map = new Bitmap(stream); 就出現 參數無效 我找了老半天 還是沒解決問題
Image1.ImageUrl = Convert.ToString(map);
}
各位大蝦 幫幫忙
我這個用的 是C# 數據庫是 sql 2005 的
希望各位 幫忙解決 不要發網址 給我看
我都 找過很多了 都解決不了
展開
總結
以上是生活随笔為你收集整理的从mysql读取图片_如何从sql数据库内读取图片的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 54888元!联想发布86英寸巨屏:兼容
- 下一篇: 紫光集团破产重整最新进展 董事长赵伟国回