zoukankan      html  css  js  c++  java
  • 从blob字段读取图片 在浏览器显示

    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);
    }
    }

  • 相关阅读:
    javascript的组成
    BOM
    相等操作符
    arguments
    数组
    Tomcat日志时间的时区问题
    利用脚本批量操作Solr集群(SolrCloud)
    Solr的schema.xml(managedschema)文件
    Solr报警告The _default configset could not be uploaded
    Ubuntu创建用户
  • 原文地址:https://www.cnblogs.com/handsomer/p/4000192.html
Copyright © 2011-2022 走看看