• .net 将数据库二进制图片在image中展示


    关键代码

                    int iLeft = (j % 3) * 360;
    
                    string strLeft = iLeft.ToString();
    
                    int iLeft0 = iLeft + 10;
                    string strLeft0 = iLeft0.ToString();
                    string  HImage ="70";
    
                    int iTop = row * 70;
                    int iTopImage = iTop - 20;
                    string strTop = iTop.ToString();
                    string strTopImage = iTopImage.ToString();
    
                    Image image = new Image();
                    image.ImageUrl = "Common/ShowImage.aspx?id=" + dt.Rows[i][3].ToString(); //获取签名
                    image.CssClass = "tmd";
                    image.Style.Add(HtmlTextWriterStyle.Left, iLeft0 + "px");
                    image.Style.Add(HtmlTextWriterStyle.Top, strTopImage + "px");
                    image.Style.Add(HtmlTextWriterStyle.Height, HImage + "px");
    
                    this.Controls.Add(image);
                    

    ShowImage.aspx

    using System;
    using System.Data.OracleClient;
    using System.Web.UI;
    
    public partial class NewFrameWorkUI_Physician_Common_ShowImage : System.Web.UI.Page
    {
        string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStringOracle10"].ToString();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ShowData();
            }
        }
        public void ShowData()
        {
            object s = Request.QueryString["id"];     
            string strSQL = "select emp_no,name,signature from staff_dict where id='" + s.ToString() + "'";
            OracleConnection connection = new OracleConnection(connectionString);
            OracleCommand cmd = new OracleCommand(strSQL, connection);
            try
            {
                connection.Open();
                OracleDataReader myReader = cmd.ExecuteReader();
                if (myReader.Read())
                {
                    if (myReader["signature"] is DBNull)
                        return;
                    Response.Clear();
                    Response.ContentType = "application/binary;";
                    Response.BinaryWrite((byte[])myReader["signature"]);
    
                    Response.Flush();
                    Response.End();
                }
            }
            catch (System.Data.OracleClient.OracleException E)
            {
                throw new Exception(E.Message);
            }
        }
    }
  • 相关阅读:
    第1周学习进度
    四则运算题1
    性能监控系统 | 从0到1 搭建Web性能监控系统
    数据库 | Oracle数据库查表空间使用情况
    性能测试 | 系统运行缓慢,CPU 100%,Full GC次数过多问题排查
    Markdown | 语法
    性能测试 | 理解单线程的Redis为何那么快?
    性能测试 | 理解分布式、高并发、多线程
    性能测试 | 常见的性能测试指标
    mysql 中varchar(50)最多能存多少个汉字
  • 原文地址:https://www.cnblogs.com/chenpanpan/p/14431668.html
Copyright © 2020-2023  润新知