表里的、包含图片的 OLE 字段我的可以!

解决方案 »

  1.   

    我的程序:
    private void FormPrint_sy_Load(object sender, System.EventArgs e)
    {

    this.dataSet .Clear ();
    this.person .Fill (dataSet);
    this.DP.Fill (dataSet);

    string sql1 ="SELECT Person_ID,Photo from Person Where Person_ID="+Person_ID;
    sqlConnection1.Open();
    SqlCommand myCommand1 =new  SqlCommand(sql1,sqlConnection1);
    SqlDataReader myReader1;
    myReader1 = myCommand1.ExecuteReader();

    if (myReader1.Read()) 
    {    
    byte[] mydata=((byte[])myReader1["Photo"]);
      FileInfo fi = new FileInfo("temp.bmp");
       FileStream myStream=fi.Open(FileMode.Create); 
       
     
    //MemoryStream myStream=new MemoryStream();
    foreach(byte a in mydata)
    {
    myStream.WriteByte(a); 
    }
    MessageBox.Show("成功读入数据!") ;

     //   stream.Write(streamByte, 0, streamByte.Length);
    // Bitmap bmp1 = new Bitmap(myStream);
    // System.Drawing.Image image = bmp1;

    // this.pictureBox1.Image=myImage;

    // Image myImage=Image.FromStream(myStream); 
    // myStream.Close();
    // this.pictureBox1.Image=myImage;
    // this.pictureBox1.Refresh();
        
    }
    else

    MessageBox.Show("没有成功读入数据!") ;
       
    }
            
    sqlConnection1.Close();

    sydjb1 sy1 =new sydjb1();
    sy1.SetDataSource (dataSet);
    crystalReportViewer1.ReportSource =sy1;
    crystalReportViewer1.SelectionFormula ="{DATA_VIEW_person.编号} ="+Person_ID;
    crystalReportViewer1.RefreshReport();
     

    }
    }
    }
      

  2.   

    可以
    问题是CR9里的图片不变,实际上TEMP.BMP变.
      

  3.   

    TEMP.BMP图片是现生成的,当在CR9里OLE后,新生成的TEMP.BMP图片可以看到(不用CR9)
    在CR9里看到是原来的TEMP.BMP(OLE时的)。
      

  4.   

    我是说插入“图片字段”,即 OLE 字段,有图片显示吗?
      

  5.   

    TEMP.BMP图片是现生成的,当在CR9里OLE后,新生成的TEMP.BMP图片可以看到(不用CR9)
    在CR9里看到是原来的TEMP.BMP(OLE时的)。
      

  6.   

    我是说数据库里的,表里的 OLE 字段……
    图片存放在表里的OLE 字段,就像其它数据库字段一样使用……
      

  7.   

    噢!
    SQL2000 图片我没有用OLE 字段 而是byte[]字段
      

  8.   

    haibodotnet(海波.NET) 是否可以给我一些原代码看看