显示上传图片 救急啊
System.Byte[] Photo = (byte[])ds.Tables[0].Rows[0][ "VclImage "];
Response.ContentType= "application/octet-stream ";
Response.BinaryWrite(Photo);
这是小弟在获取数据库图片后,直接将它显示在页面上
现在出现问题了
我想将流放到控件里面来显示图片
请问该怎么实现和转换
请大家说的详细点,描述和代码多点
谢谢拉
[解决办法]
<asp:Image ID= "imgShow " runat= "server " Width= "180 " Height= "180 " ImageUrl= 'image.aspx?ID=0 ' />
----
image.aspx
int photoID = int.Parse(this.Request[ "PhotoID "]);
PhotoContent pc = PhotoContentManager.GetPhotoContent(photoID);
this.Response.ContentType = "image/pjpeg ";
this.Response.BinaryWrite(pc.FileData);
[解决办法]
不是说了吗,你要定义输出类型的。页面流当然是下载窗口了。
Response.ContentType= "image/jpeg ";
[解决办法]
SqlConnection conn = new SqlConnection( "server=localhost;database=tu;uid=xiaotu;pwd=625811; ");
conn.Open();
string cmdText = "select origitalbmp from studentinfotb where gkh= '07310230154911 ' ";
SqlCommand cmd = new SqlCommand(cmdText, conn);
SqlDataReader dr = cmd.ExecuteReader();
byte[] imageByte = null;
if (dr.Read())
{
imageByte = (byte[])dr[0];
}
conn.Close();
System.IO.MemoryStream ms = new System.IO.MemoryStream(imageByte);
pictureBox1.Image = Image.FromStream(ms);//picturebox1是picturebox控件
其它的控件道理是一样的