45fan.com - 路饭网

搜索: 您的位置主页 > 网络频道 > 阅读资讯:怎么样通过ASP.NET实现从数据库中读取图片?

怎么样通过ASP.NET实现从数据库中读取图片?

2016-09-02 09:39:40 来源:www.45fan.com 【

怎么样通过ASP.NET实现从数据库中读取图片?

在ASP.NET中,我们可以用下面的方法实现从数据库中读取图片并显示在页面上,方法如下:

SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["ConnStr"]);

String sql="SELECT imageFROM append where id='" + strID + "'";

SqlCommand command=new SqlCommand(sql,conn);

conn.Open();

SqlDataReader dr=command.ExecuteReader();

dr.Read();

byte[] imgdata = (byte[])dr["image"];

Response.BinaryWrite(imgdata);

dr.Close();

conn.Close();

本文地址:http://www.45fan.com/a/question/71202.html
Tags: 实现 数据库 ASP.NET
编辑:路饭网
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部