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