zoukankan      html  css  js  c++  java
  • c# 读数据库二进制流到图片

    public Bitmap PictureShow(string connectionString, string opName, string productType)
            {
                SqlConnection conn = new SqlConnection(connectionString);
                conn.Open();
                //MessageBox.Show("连接成功");
                string sqlCmd = "select 产品图片 from Tupian where 产品型号='" + productType + "' and 工位号='" + opName + "'";
                SqlCommand command = new SqlCommand(sqlCmd, conn);
                DataSet dtSet = new DataSet();
                SqlDataAdapter myDataAdapter = new SqlDataAdapter(sqlCmd, conn);
                myDataAdapter.Fill(dtSet);
                DataTable dt = dtSet.Tables[0];
                byte[] bufferByte = (byte[])dt.Rows[0]["产品图片"];//将二进制流转化成图片
                MemoryStream ms = new MemoryStream(bufferByte, true);
                ms.Write(bufferByte, 0, bufferByte.Length);
                Bitmap bmpt = new Bitmap(ms);
                return  bmpt;
            }

    实现单张读取。

  • 相关阅读:
    ApplicationContext.xml修改
    springmvc.xml约束
    log4j.properties
    SqlMapConfig.xml配置文件
    Mybatis注解式开发坐标
    字符串函数
    vim基础快捷键
    format的使用
    lambda匿名函数
    字典的基础使用
  • 原文地址:https://www.cnblogs.com/hanjiaxu/p/3200440.html
Copyright © 2011-2022 走看看