ICANN认证国际域名顶级注册机构
网站建设,域名注册,空间租用,软件销售,广告设计 域名注册,空间租用, 网站建设,东莞网页设计,域名注册,网站推广,网站开发,网页设计 网站推广,,百度推广,新浪推广,雅虎推广,网易推广 标志设计,画册设计,包装设计,VI策划,企业形象顾问 连邦软件加盟店,提供销遥行,管家婆,速达,用友ERP,诺顿等软件报价及销售 建站必读 腾达网络,上网帮助中心, 腾达为东莞等地,提供网站建设,网站推广,广告设计,软件销售等优质服务!
建站必读


 
 
当前位置:首页 -> 建站必读 -> ASP技术
如何正确显示数据库中的图片
文件1:showimage.aspx.cs





namespace ImageResizing {



public class MainDisplay : System.Web.UI.Page {



public void Page_Load(System.Object sender, System.EventArgs e) {



try {



System.Int32 _ImgID = System.Convert.ToInt32(Request.QueryString["ImgID"]);



System.Int32 _height = System.Convert.ToInt32(Request.QueryString["height"]);



System.Int32 _width = System.Convert.ToInt32(Request.QueryString["width"]);



System.Data.SqlClient.SqlConnection Con = new System.Data.SqlClient.SqlConnection( "server=localhost;database=northwind;trusted_connection=true" );



System.String SqlCmd = "SELECT * FROM Images WHERE ImageID = @ImageID";



System.Data.SqlClient.SqlCommand SqlCmdObj = new System.Data.SqlClient.SqlCommand( SqlCmd, Con );



SqlCmdObj.Parameters.Add("@ImageID", System.Data.SqlDbType.Int).Value = _ImgID;



Con.Open();



System.Data.SqlClient.SqlDataReader SqlReader = SqlCmdObj.ExecuteReader();



SqlReader.Read();



System.Web.HttpContext.Current.Response.ContentType = "image/pjpeg";



System.Drawing.Image _image = System.Drawing.Image.FromStream( new System.IO.MemoryStream( (byte[])SqlReader["Image"] ) );



System.Drawing.Image _newimage = _image.GetThumbnailImage( _width, _height, null, new System.IntPtr());



_newimage.Save( System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg );



} catch (System.Exception Ex) {



System.Web.HttpContext.Current.Trace.Write(Ex.Message.ToString());



}



}



}



}





文件2:显示图片之用,把querystring传入

<html>

<body>



<img src="showimage.aspx?ImgID=202&height=150&width=150">

</body>

</html>




 
 
本站关键词:
|东莞广告公司|东莞广告设计|网站建设东莞|东莞网站制作|东莞网站推广|东莞国内域名注册|网页开发|域名注册|空间租用|东莞网站开发|东莞企业网站建设|国际内域名注册||东莞广告公司|东莞广告设计|网站建设东莞|东莞网站制作|东莞网站推广|东莞国内域名注册|网页开发|域名注册|空间租用|东莞网站开发|东莞企业网站建设|国际内域名注册||东莞广告公司|东莞广告设计|网站建设东莞|东莞网站制作|东莞网站推广|东莞国内域名注册|网页开发|域名注册|空间租用|东莞网站开发|东莞企业网站建设|国际内域名注册||东莞广告公司|东莞广告设计|网站建设东莞|东莞网站制作|东莞网站推广|东莞国内域名注册|网页开发|域名注册|空间租用|东莞网站开发|东莞企业网站建设|国际内域名注册||东莞广告公司|东莞广告设计|网站建设东莞|东莞网站制作|东莞网站推广|东莞国内域名注册|网页开发|域名注册|空间租用|东莞网站开发|东莞企业网站建设|国际内域名注册||东莞广告公司|东莞广告设计|网站建设东莞|东莞网站制作|东莞网站推广|东莞国内域名注册|网页开发|域名注册|空间租用|东莞网站开发|东莞企业网站建设|国际内域名注册||东莞广告公司|东莞广告设计|网站建设东莞|东莞网站制作|东莞网站推广|东莞国内域名注册|网页开发|域名注册|空间租用|东莞网站开发|东莞企业网站建设|国际内域名注册|
域名注册 | 虚拟主机 | 网站建设 | 网站推广 | 广告设计 | 帮助中心 | 软件中心 | 关于腾达
东莞市腾达信息工程有限公司      本站网络实名: 东莞网站建设
地址:东莞市新城市中心区第一国际B座610   邮编:523007
电话:0769-22026071 22026072 传真:0769-22026076 24小时服务热线:13712032014
© 2002~2005 腾达网络   版权所有