I have an image stored in my MS Access database with the data type OLE Object. I want it to display in an Image
control. How can I do this? I tried this, but only in a PictureBox
control in windows forms. Please help. Thanks in advance.
You need to create a page that can read the image from the database as binary data, then write that data directly to http response as binary data using Response.BinaryWrite to feed the image out. Then the src attribute of your image is pointed at the page itself like:
<img src="image.aspx" />
And the code behind image.aspx:
// An assumed method to get binary data our of the database
var bytes = YourDataLayer.GetBinaryImageData();
Response.Clear();
Response.AddHeader("Content-Disposition","attachment;filename=filename.jpg");
Response.ContentType = @"image\jpg";
Response.BinaryWrite(bytes);
Response.End();
从数据库中读取图像作为字节数组,然后创建一个临时图像对象,并将其分配给页面上的webcontrol
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.