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 ())
{
Repeated lelob mylob = dr. get1_lelob (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 );
}
}
Reading images from BLOB fields is displayed in the browser