将图像从sql server加载到图像控件asp.net
问题描述:
朋友,
将图像保存到具有图像类型的sql server字段中是可以的,
现在如何将该图像加载到诸如asp.net中的图像控件的控件中(在运行时!)
我在WinForm中使用此代码,并且可以正常工作:
hi friends,
saving image to sql server field with image type is ok,
now how could I load this image to a control such as image control in asp.net ( in runtime ! )
I use this code in WinForm and it works:
cmd.CommandText = "SELECT image FROM table1 where id='U07WL'";
cmd.CommandType = CommandType.Text;
SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
byte[] barrImg = (byte[])reader["image"];
string strfn = Convert.ToString(DateTime.Now.ToFileTime());
FileStream fs = new FileStream(strfn, FileMode.CreateNew, FileAccess.Write);
fs.Write(barrImg, 0, barrImg.Length);
fs.Flush();
fs.Close();
panel1.BackgroundImage = Image.FromFile(strfn);
但是在asp.net中,我们没有backgroundImage属性,例如,我们有ImageUrl!有什么办法!?
对不起,我的解释不好,英语不好,
感谢advande
but in asp.net we don''t have backgroundImage property, instead we have ImageUrl for example ! is there any way !?
excuse my bad explanation and bad english,
thanks in advande
答
引用
在ASP中显示数据库中的图像 [显示/存储并从数据库到Gridview以及检索图像数据在鼠标悬停上 [ ^ ]
还是简单的一个
SQL数据库映像存储和简易缩略图 [ ^ ]
谢谢.
Refer
Display Images from Database in ASP[^]
Or
Display/Store and Retrieve Image Data from Database to Gridview, and also on Mouse Over[^]
Or simple one
SQL Database Image Storage & Easy Thumbnails[^]
Thanks.