声明是在WinFrom中,不是WebFrom 
声明是在WinFrom中,不是WebFrom
声明是在WinFrom中,不是WebFrom
声明是在WinFrom中,不是WebFrom
声明是在WinFrom中,不是WebFrom
声明是在WinFrom中,不是WebFrom
声明是在WinFrom中,不是WebFrom
声明是在WinFrom中,不是WebFrom

解决方案 »

  1.   

    picture 的类型为byte[],存放的是从数据库Image类型的字段中读出的流。
                数据库访问时的数据类型为 DbType.Binary
                以下为显示图片的代码:
                 //声明一个MemoryStream的变量,来存放picture
                MemoryStream memoryStream = new MemoryStream(Picture);
                
                //Bitmap变量用来显示照片
                Bitmap bitMap=null;            //如果图片的长度>0
                if (model.Picture.Length > 0)
                {
                    //按照图片流picture生成的bitMap
                    bitMap = new Bitmap(memoryStream);
                    
                    //将bitmap赋值给pictureBox以显示照片
                    this.pictureBox2.Image = bitMap;
                }
                
    图片如何在SQL Server数据库中存取请参考 :
    http://www.cnblogs.com/anshangcun/archive/2007/09/27/908171.html 
      

  2.   

    while(dr.read())
                    {
                        if (dr["照片"] != DBNull.Value)
                        {
                            Image photo = new Bitmap(new MemoryStream((byte[])dr["照片"]));
                        }                }
      

  3.   

            
    private byte[] photo;
    private System.Windows.Forms.PictureBox pctBox; if(dr["照片"]!=System.DBNull.Value)
    {
    try
    {
    this.photo=(byte[])dr["照片"];
    System.Drawing.ImageConverter ic=new ImageConverter();
    this.pctBox.Image=(Image)ic.ConvertFrom(this.photo);
    }
    catch{;}
    }
    else
    {
    this.pctBox.Image=null;
    this.photo=null;
    }