2013-09-29 36 views
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; 
} 

回答

0

在Crystal报表的Field Explorer只是Cheking是否两个表中其Database Field补充说,如果不是比添加后能够正常工作。