2011-04-08 2 views
0

독립형 DataSet (모든 유형의 데이터베이스에 연결되어 있지 않음) 만있는 응용 프로그램에서 Crystal Reports로 보고서를 생성해야합니다. 또한 DataTable의 값을 기반으로 보고서를 생성해야합니다.DataSet 및 DataTable에서 Crystal Reports 생성

나를 통해 보여 주시겠습니까, 나는 초보자입니다. 템플릿이 있지만 DataTable에서 보고서를 생성하는 방법이나 템플릿에 삽입하는 방법을 알지 못합니다.

답변

5

이 기사는 당신을위한 것입니다.

Crystal Report with DataSet and DataTable using C#

  • 우리의 데이터 소스에 우리의 보고서를 바인딩

    using System; 
    using System.Collections.Generic; 
    using System.ComponentModel; 
    using System.Data; 
    using System.Drawing; 
    using System.Text; 
    using System.Windows.Forms; 
    using System.Data.OracleClient; 
    using System.IO; 
    
    namespace CrystalReportWithOracle 
    { 
        public partial class frmMain : Form 
        { 
         public frmMain() 
         { 
          InitializeComponent(); 
         } 
    
         private void frmMain_Load(object sender, EventArgs e) 
         { 
          my_rpt objRpt; 
          // Creating object of our report. 
          objRpt = new my_rpt(); 
    
          String ConnStr = "SERVER=mydb;USER ID=user1;PWD=user1"; 
    
          OracleConnection myConnection = new OracleConnection(ConnStr); 
    
          String Query1 = "select a.PROJECT_ID,a.PROJECT_NAME,b.GROUP_NAME from 
          tbl_project a,tbl_project_group b where a.group_code= b.group_code"; 
    
          OracleDataAdapter adapter = new OracleDataAdapter(Query1, ConnStr); 
    
          DataSet Ds = new DataSet(); 
    
          // here my_dt is the name of the DataTable which we 
          // created in the designer view. 
          adapter.Fill(Ds, "my_dt"); 
    
          if (Ds.Tables[0].Rows.Count == 0) 
          { 
           MessageBox.Show("No data Found", "CrystalReportWithOracle"); 
           return; 
          } 
    
          // Setting data source of our report object 
          objRpt.SetDataSource(Ds); 
    
          CrystalDecisions.CrystalReports.Engine.TextObject root; 
          root = (CrystalDecisions.CrystalReports.Engine.TextObject) 
           objRpt.ReportDefinition.ReportObjects["txt_header"]; 
          root.Text = "Sample Report By Using Data Table!!"; 
    
          // Binding the crystalReportViewer with our report object. 
          crystalReportViewer1.ReportSource = objRpt; 
         } 
        } 
    } 
    

편집 : 또한이 보일 것이다;

ADO.NET Datatable as Crystal Report datasource

How do I populate Crystal Reports, using a DataTable?

+0

살아라 내 보고서 템플릿이며이 파일로 프로젝트에 추가되고 있으며, 나는 그것을로드해야하고 내가 어떤 결정 보고서가 실제로 뷰어가없는 것입니다. 어떻게해야합니까? –

+0

@Faulty 나는 너가이 기사를 절대적으로 읽었다 고 생각한다 http://www.c-sharpcorner.com/uploadfile/mahesh/crystalreportsintroduction11082005014959am/crystalreportsintroduction.aspx –