Hi I am trying to retrieve pProductImage that contains ie. ~/Images/pic1.jpg (images url) from products table and use the pProductId as a identifier to display different images according to the Id.
this is my cataglogue.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();
}
}
and in my cataglogue.aspx (the image to display in the image control)
<div>
<img src="Catalogue.aspx?pProductId=2" alt="" />
</div>
Response.BinaryWrite((byte[])rdr["pProductImage"]);- शेखर