public byte[] GetProImg(string JID)
{
byte[] Buffer = null;

using (OracleConnection conn = new OracleConnection(Pub.ConnectionString))
{
try
{
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "select PDC_FJ from tb t where JID= :p1";
cmd.Parameters.AddWithValue("p1", JID);
OracleDataReader dr = cmd.ExecuteReader(CommandBehavior.SequentialAccess);
if (dr.Read())
{
OracleLob myLob = dr.GetOracleLob(0);
int myLength = Convert.ToInt32(myLob.Length);
Buffer = new byte[myLength];
myLob.Read(Buffer, 0, myLength);
}
dr.Close();
}
catch (System.Data.OracleClient.OracleException ex)
{
throw new Exception(ex.Message);
}
finally
{
conn.Close();
}

}
return Buffer;
}

img.aspx:

protected void Page_Load(object sender, EventArgs e)
{
JHAC.BLL.Product bllpro = new JHAC.BLL.Product();
string jid = "";
if (Page.Request["Jid"] != null && Page.Request["Jid"].ToString() != "")
{
jid = Page.Request["Jid"].ToString();
}
byte[] imgByte = bllpro.GetProImg(jid);
if (imgByte != null)
{
this.Response.Clear();
this.Response.BinaryWrite(imgByte);
}
}

05-08 14:56