int ImgID=Convert.ToInt32(Request.QueryString["imgid"]);
frame.bin.OracleProc OraProc=new frame.bin.OracleProc();
string sql="select id,photo from pro_t_workerinfo where id="+ImgID;
OracleDataReader ord=OraProc.ExecuteReader(sql);
if (ord.Read())
{
Response.BinaryWrite((byte[])ord["photo"]);
Response.End(); 
}
ord.Close();
OraProc.ConnClose();代码是这样写的,是从网上看到的,说这样可以把图片显示在页面上,可是我的却显示不出来,谢谢各位了,解决者重谢

解决方案 »

  1.   

    下面是显示图片的页面showimg.aspx后台代码,该页面不需要放任何东西.
    --------------------------------------------------------------------
    //创建数据库连接
    OracleConnection myConnection = new OracleConnection(ConfigurationSettings.AppSettings["sysDSN"]);
    myConnection.Open();//打开数据库
    OracleCommand myCommand = myConnection.CreateCommand();
    string sql = "select tmp_blob from tmp where tmp_id = 103";
    myCommand.CommandText = sql;
    OracleDataReader myRead = myCommand.ExecuteReader();//开始读取
    myRead.Read();
    //这个方法更直接
    Byte[] Buffer = (Byte[])myRead[0];
    //OracleLob myLob = myRead.GetOracleLob(0);
    //长度是long,转为int32
    //int myLength = Convert.ToInt32(myLob.Length);  
    //Byte[] Buffer = new byte[myLength];      
    //myLob.Read(Buffer,0,myLength);//输出
    this.Response.Clear();
    //输出mime类型,根据上传的文件取到的mimetype,是什么我忘记了,自己写上,不过不写也没有关系.
    this.Response.ContentType = "";
    this.Response.BinaryWrite(Buffer);
    this.Response.End();
      

  2.   

    数据库里有数据么,提示错误是什么?
    楼主莫非就是发贴不结的那位?!====================================================
        角落里的理想 http://blog.csdn.net/zdsdiablo/
    ====================================================
      

  3.   

    错误信息是:GIF89a? 剣X?楼上的别误会,一定会结贴的
      

  4.   

    HttpPostedFile  UpFile  =  UP_FILE.PostedFile;   
    string tmp=UpFile.ContentType;
    FileLength  =  UpFile.ContentLength;          
    Byte[]  FileByteArray  =  new  Byte[FileLength];      
    Stream  StreamObject  =  UpFile.InputStream;        
    StreamObject.Read(FileByteArray,0,FileLength);保存到数据库中的代码用的是这个,oracle数据库字段用的是blob类型的