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

时间:2013-09-29 06:02:19

标签: c# crystal-reports

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

1 个答案:

答案 0 :(得分:0)

Field Explorer Crystal报告中Just Cheking是否在其Database Field中添加了两个表,如果不是在添加它之后正常工作。