怎么样通过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();