关于图片显示,有重谢
我将图片存进数据库的代码是:
Stream fyj=zsfyj.PostedFile.InputStream;
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand comm=new SqlCommand();
comm=new SqlCommand("insert into tb_yg_xxjl(zsfyj,bz) values ('" + fyj + "','" + bz.Text + "')",conn);
conn.Open();
comm.ExecuteNonQuery();
我试图将图片查询显示出来的相关代码是:
<IMG alt="" src="yb_byzfyj.aspx?id=<%= id.Value %>" border=0 >
文件yb_byzfyj.aspx的相关代码如下:
private void Page_Load(object sender, System.EventArgs e)
{
string id=Request.QueryString["id"];
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand comm=new SqlCommand("Select zsfyj from tb_yg_xxjl where id='" + id + "'",conn);
conn.Open();
SqlDataReader re=comm.ExecuteReader();
while (re.Read())
{
Response.BinaryWrite((byte[])re["zsfyj"]);
}
}
我想尽办法就是不能显示出来。哪位高手告诉我原因。详细点拜托了,我好苯的。呵呵