0

在水晶报表中,我试图显示两个表格datatset ds,但只有表格 [0] 显示在水晶报表中,table[1]没有显示为什么会这样,我检查了表格 [1] 数据是否正确填写,在哪里问题?

private void ViewR_Load(object sender, EventArgs e)
        {
            String str = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string path = str + "\\images\\";

            CrystalReportP objRpt;
            // Creating object of our report.
            objRpt = new CrystalReportP();
            DataSetPatient ds = new DataSetPatient(); // .xsd file name
            DataTable dt = DBHandling.GetPatient();
            ds.Tables[0].Merge(dt);

            DataTable dt1 = new DataTable();

            //dt1.Columns.Add("Images", typeof(Bitmap));
            dt1.Columns.Add("Images", typeof(Byte[]));


            if (System.IO.Directory.Exists(path))
            {
                string[] allImg = System.IO.Directory.GetFiles(path);
                foreach (string imgName in allImg)
                {
                    drow = dt1.NewRow();
                    // define the filestream object to read the image 
                    FileStream fs;
                    // define te binary reader to read the bytes of image 
                    BinaryReader br;
                    // check the existance of image 

                        // open image in file stream 
                        fs = new FileStream(imgName, FileMode.Open);


                    // initialise the binary reader from file streamobject 
                    br = new BinaryReader(fs);
                    // define the byte array of filelength 
                    byte[] imgbyte = new byte[fs.Length + 1];
                    // read the bytes from the binary reader 
                    imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
                    drow[0] = imgbyte;
                    // add the image in bytearray 
                    dt1.Rows.Add(drow[0]);
                    // add row into the datatable 
                    br.Close();
                    // close the binary reader 
                    fs.Close();
                    // close the file stream 
                }
            }
                    try
            {

                    ds.Tables[1].Merge(dt1);
            }
            catch (Exception r)
            {

            }

            objRpt.SetDataSource(ds);
            crystalReportViewer1.ReportSource = objRpt;
}
4

1 回答 1

0

Field ExplorerCrystal 报告中 Just Cheking 是否在其中添加了两个表Database Field,如果没有,则在添加后它可以正常工作。

于 2013-09-29T11:41:48.207 回答