http://search.csdn.net/Expert/topic/1102/1102789.xml?temp=.5734674

解决方案 »

  1.   

    using System.Data;
    using System.Data.SqlClient;
    using System.IO;
    using System;
    //读取二进制流
    public class ReadByte
    {
    public static void Main(string[] args)
    {
    const string constr = "workstation id=NBPC;packet size=4096;integrated security=sspi;initial catalog=Northwind;persist security info=False";
    SqlConnection con = new SqlConnection(constr);
    const string cmdstr = "Select pub_id,pr_info,logo From pub_info where pub_id = '0736'";
    SqlCommand cmd = new SqlCommand(cmdstr,con);
    con.Open();
    SqlDataReader byteRead = cmd.ExecuteReader();
            //声明内存流
    MemoryStream stream = new MemoryStream();
    //二进制流
    BinaryWriter writer = new BinaryWriter(stream);
    //参数
    int BufferSize = 1024;
    byte[] Buffer = new byte[BufferSize];
    long Offset =0;
    long BytesRead =0;
            //使用方法见(.NET学习笔记)
            do
    {
    BytesRead = byteRead.GetBytes(2,Offset,Buffer,0,BufferSize);
    writer.Write(Buffer,0,(int)BytesRead);
    writer.Flush();
    Offset += BytesRead;
    }while(BytesRead==BufferSize);   //读取到末尾退出
    }}参照以上的程序 改成WinForm的 生成Image对象 并赋给PictureBox的image属性
      

  2.   

    我的程序:
    请高手帮忙分析一下!!string sql="select image1 from 表 where id=18";
    DataSet ds =QuerySqlDataSet(sql);
    MemoryStream stream = new MemoryStream((byte[])ds.Tables[0].Rows[0][0]);
    Image image = Image.FromStream(stream);
    this.pictureBox1.Image=image;