比如我现在有一表:TB
有字段:Name,Sex,Age,Photo
其中Photo字段为Image类型现在我建了一个rpt,用crystalreportview显示报表
问:如何将Photo在报表中显示出来,高手请帮忙,谢谢~~

解决方案 »

  1.   

    Response.BinaryWrite((byte[])nw.Photo);
    但是我不会在image控件中显示。不知道有人会吗?
      

  2.   

    请楼上的指点一下。
    如果用Response.BinaryWrite就会在一个新的页面中打开。如果在控件中同一页面中打开,应该如何操作。
      

  3.   

    在WINFORM下CryStalReport显示图片哟
    哪里有资料,请大虾共享一下,谢谢了!
      

  4.   

    把图片写入SQL数据库,在程序中建一个数据集,把这张表加入数据集,直接把这个图片字段拖到报表上面就可以显示了,不需做任何动作
    如果想显示不同图片,这个数据表中图片字段不要赋值,让他空着加载到dataset中,然后在程序某个按钮事件中:
    byte[] bys = cardWeb.DownloadPhoto(strcardid, strunitid);
    FileStream fs = new FileStream(@"D:\image\财务部.jpg", FileMode.OpenOrCreate, FileAccess.Read);
    bys = new byte[fs.Length];
    fs.Read(bys, 0, System.Convert.ToInt32(fs.Length));
    fs.Close();
    ds.Tables["Chk_CardTitle"].Rows[0]["Img"] = bys;
    crystalreportview.RefreshReport();
    这样就可以显示不同的图片了
      

  5.   

    byte[] bys = cardWeb.DownloadPhoto(strcardid, strunitid);
    这句改一下,那事我吊的别的方法,^_^
      

  6.   

    兄弟,我按照那样的方法得不到图片呀,结果显示为“System.Byte []”
    代码:
    byte[] mydata = ((byte[])ds.Tables[0].Rows[0]["ImgData"]);
    FileInfo fi = new FileInfo("temp");
    FileStream fs = fi.Open(FileMode.Create);
    mydata = new byte[fs.Length];
    fs.Read(mydata, 0, System.Convert.ToInt32(fs.Length));
    fs.Close();
    card.Tables[0].Rows[0]["Photo"] = mydata;CardRpt rpt = new CardRpt();
    rpt.SetDataSource(card.Tables[0]);
    crystalReportViewer1.ReportSource = rpt;其中card是一个数据集,ds.Tables[0].Rows[0]["ImgData"])是从数据库中读取存储的图片字段
    这样写有问题吗,请指正,谢谢~~
      

  7.   

    byte[] mydata = ((byte[])ds.Tables[0].Rows[0]["ImgData"]);
    改为byte[] mydata;
    这是换不同的图;
    若不换,不要写代码,直接拖Photo进RPT就行了
      

  8.   

    CrystalReport本身就支持image类型的显示
      

  9.   

    老兄看下面的两个贴子:
    http://blog.csdn.net/haibodotnet/archive/2004/04/12/21570.aspxhttp://www.cnblogs.com/oosnoopy/archive/2005/12/17/299022.html
      

  10.   

    用一个空白网页,cs文件或其他的都可以(只是使用时有细微的区别),网页(其他一样)完成的唯一功能就是Response.BinaryWrite((byte[])nw.Photo);
    然后用image控件定位到这个网页(其他一样),或用IMG定位到这个网页(其他一样)就可以了
      

  11.   

    这个可以。。我实现了
    public static byte[] GetPhoto(string filePath)  //函数
    {

    FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
    BinaryReader br = new BinaryReader(fs);
    byte[] photo = br.ReadBytes((int)fs.Length);
    br.Close();
    fs.Close();
        return photo;
    } public void seephoto() //读取 SQL图片
    {
    try
    {
    string ConnectionString ="server=.;uid=sa;pwd=;database=system";     
    SqlConnection conn=new SqlConnection(ConnectionString);
    string sql="select Student_Photo from Student_Table where Student_Bianhao='"+this.label16.Text+"'";
    SqlCommand command = new SqlCommand(sql,conn);
    conn.Open();
    SqlDataReader dr = command.ExecuteReader(CommandBehavior.SequentialAccess);
    if(dr.Read())
    {
    MemoryStream ms = new MemoryStream(((byte[])dr["Student_Photo"]));  
    this.pictureBox1.Image = Image.FromStream(ms,true);
    }
    else

    MessageBox.Show("没有成功读入数据!") ;
       
    }
            
    conn.Close();
    }
    catch(Exception x)
    {
    MessageBox.Show(x.Message);
    }
    }