在水晶报告中,数据集中的第二个表未显示



在水晶报告中,我试图显示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;
}

在水晶报告Field Explorer只是检查是否在其Database Field中添加了两个表,如果没有,则添加后它工作正常。

最新更新