DATALIST中绑定一个image控件 ,这个控件如果显示数据库中image字段的图片? 类似http://dotnet.aspx.cc/ShowDetail.aspx?id=ECD9AE16-8FF0-4A1C-9B9F-5E8B641CB1B1 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个字段是image型,不是字符型的,这样好像是读不出来 http://dev.csdn.net/article/28/28352.shtm 设置image的ImageUrl为"LoadRPhoto.aspx"在LoadRPhoto.aspx中加载图片:private void LoadNoPicture()//加载默认照片 { System.IO.FileStream imgFStream = new System.IO.FileStream(this.Server.MapPath(".") + "\\pic\\NoPhoto.gif",System.IO.FileMode.Open,System.IO.FileAccess.Read);//声明一个公开以文件为主的流 System.IO.BinaryReader imgBReader = new System.IO.BinaryReader(imgFStream); System.Byte[] imgBinaryData = imgBReader.ReadBytes(System.Convert.ToInt32(imgFStream.Length)); this.Page.Response.BinaryWrite(imgBinaryData); } private void LoadCadaverPhoto(string p_BodyId,string p_Serialer)//加载照片 { try { this.OraConnData.Open(); System.Data.OracleClient.OracleCommand OraAdaLoadCadaverPhoto = new System.Data.OracleClient.OracleCommand("SELECT PHOTO FROM CASE_S_WMSTPHOTO WHERE BODYID = '"+p_BodyId+"' AND SERIALER = '"+p_Serialer+"'",this.OraConnData); System.Data.OracleClient.OracleDataReader OraDrLoadCadaverPhoto = OraAdaLoadCadaverPhoto.ExecuteReader(); if(OraDrLoadCadaverPhoto.Read()) { System.Web.HttpContext.Current.Response.ContentType = "images/*"; if(OraDrLoadCadaverPhoto["PHOTO"].ToString().Trim() != "") { this.Page.Response.BinaryWrite((byte[])OraDrLoadCadaverPhoto["PHOTO"]); } else { this.LoadNoPicture(); } } else { this.LoadNoPicture(); } } catch { this.LoadNoPicture(); } finally { this.OraConnData.Close(); } } int1 = Trim(Request.QueryString("编号")) SqlConnection1.ConnectionString = "user id=sa;data source=wiecoffice;persist security info=False;initial catalog=wiecweb;password=" & Trim(name) SqlCommand1.CommandText = "select * from 商品 where 编号='" & Trim(CType(int1, String)) & "'" SqlConnection1.Open() SqlCommand1.Connection.Open() Dim Sqldatareader1 As System.Data.SqlClient.SqlDataReader = SqlCommand1.ExecuteReader(CommandBehavior.CloseConnection) If Sqldatareader1.Read() Then Response.BinaryWrite(Sqldatareader1.Item("image"))我这样写,怎么读不出来 网站流量监控 让文本框的值不改变 我是用Membership做的登录效果,我想判断用户是否已登录? 一个关于查询显示的小问题 如何将后台动态生成表格加入到前台指定位置 Forms基于角色授权验证下,COOKIE的持久性问题请教老大们~ asp.net email 发送大附件问题....急。。。。。 ResGen.read.1.tlog怎么删除? IIS6.0 网站属性没有ASP.NET 选项卡 多条件查询拼接sql语句如何防止sql注入 选择文件上传控件(input type=file)是否是只能选择小于4M的文件啊? 关于DropDownList下拉事件
在LoadRPhoto.aspx中加载图片:
private void LoadNoPicture()//加载默认照片
{
System.IO.FileStream imgFStream = new System.IO.FileStream(this.Server.MapPath(".") + "\\pic\\NoPhoto.gif",System.IO.FileMode.Open,System.IO.FileAccess.Read);//声明一个公开以文件为主的流
System.IO.BinaryReader imgBReader = new System.IO.BinaryReader(imgFStream);
System.Byte[] imgBinaryData = imgBReader.ReadBytes(System.Convert.ToInt32(imgFStream.Length));
this.Page.Response.BinaryWrite(imgBinaryData);
} private void LoadCadaverPhoto(string p_BodyId,string p_Serialer)//加载照片
{
try
{
this.OraConnData.Open();
System.Data.OracleClient.OracleCommand OraAdaLoadCadaverPhoto = new System.Data.OracleClient.OracleCommand("SELECT PHOTO FROM CASE_S_WMSTPHOTO WHERE BODYID = '"+p_BodyId+"' AND SERIALER = '"+p_Serialer+"'",this.OraConnData);
System.Data.OracleClient.OracleDataReader OraDrLoadCadaverPhoto = OraAdaLoadCadaverPhoto.ExecuteReader();
if(OraDrLoadCadaverPhoto.Read())
{
System.Web.HttpContext.Current.Response.ContentType = "images/*";
if(OraDrLoadCadaverPhoto["PHOTO"].ToString().Trim() != "")
{
this.Page.Response.BinaryWrite((byte[])OraDrLoadCadaverPhoto["PHOTO"]);
}
else
{
this.LoadNoPicture();
}
}
else
{
this.LoadNoPicture();
}
}
catch
{
this.LoadNoPicture();
}
finally
{
this.OraConnData.Close();
}
}
SqlConnection1.ConnectionString = "user id=sa;data source=wiecoffice;persist security info=False;initial catalog=wiecweb;password=" & Trim(name)
SqlCommand1.CommandText = "select * from 商品 where 编号='" & Trim(CType(int1, String)) & "'"
SqlConnection1.Open()
SqlCommand1.Connection.Open() Dim Sqldatareader1 As System.Data.SqlClient.SqlDataReader = SqlCommand1.ExecuteReader(CommandBehavior.CloseConnection)
If Sqldatareader1.Read() Then
Response.BinaryWrite(Sqldatareader1.Item("image"))
我这样写,怎么读不出来