C#中从数据库取出图片如何直接显示在网页上
作者:编撰 转贴自:参考 点击数:2179 文章录入:
zhaizl
SqlConnection cn=new SqlConnection(conn); SqlCommand cmd=new SqlCommand(); cmd.CommandText= "select Image from UpImage ";//查询语句 cmd.Connection=cn; cn.Open(); this.Response.ContentType= "image/jpeg "; //this.Response.ContentType= "image/bmp "; //this.Response.ContentType= "image/gif "; SqlDataReader dr=cmd.ExecuteReader(); while(dr.Read()) { this.Response.BinaryWrite((byte[])dr[ "Image "]);//显示图片 } cn.Close();
上一篇文章:
C#正则表达式语法规则
下一篇文章:
给ueditor编辑器赋值
|