您好我正在尝试检索包含 ie 的 pProductImage。~/Images/pic1.jpg (images url) 来自 products 表,并使用 pProductId 作为标识符,根据 Id 显示不同的图像。
这是我的 catalogue.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.OleDb;
public partial class Catalogue : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string ImageId = Request.QueryString["Img"];
string sqlText = "SELECT pProductImage FROM Products WHERE pProductId = " +ImageId;
OleDbConnection mDB = new OleDbConnection(ConfigurationManager.ConnectionStrings["AccessConnection"].ConnectionString);
OleDbCommand cmd = new OleDbCommand(sqlText, mDB);
mDB.Open();
OleDbDataReader rdr = cmd.ExecuteReader();
if (rdr.Read())
{
Response.BinaryWrite((byte[])rdr["pProductImage"]);
}
mDB.Close();
}
}
在我的 cataglogue.aspx 中(要在图像控件中显示的图像)
<div>
<img src="Catalogue.aspx?pProductId=2" alt="" />
</div>