【问题标题】:In crystal report ,2nd table from dataset not getting displayed在水晶报表中,数据集中的第二个表未显示
【发布时间】:2013-09-29 19:41:48
【问题描述】:

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

【问题讨论】:

    标签: c# crystal-reports


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多