将图像从sql server加载到图像控件asp.net [英] load image from sql server to image control asp.net

查看:85
本文介绍了将图像从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.


这篇关于将图像从sql server加载到图像控件asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆