Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I have developed a windows Form application in C# and Sqlite DB. Applicatio have crystal Report & Dataset I have added table fields from Database field to crystal report. The problem is when I run the application values are not displayed in crystal report only Field names are displayed. When I check DataTable the selected row values are there in dt. but I can't bind that to crystal report following is the code.

Thank you


private void crystalReportViewer1_Load(object sender, EventArgs e)
        {
            this.crystalReportViewer1.RefreshReport();
            SQLiteConnection cn = new SQLiteConnection(sett.con);

            string BillPath = System.AppDomain.CurrentDomain.BaseDirectory;
            if (BillPath.EndsWith("\\bin\\Debug\\"))
            {
                BillPath = BillPath.Replace("\\bin\\Debug\\", "");
            }
            DataTable dt = new DataTable();
            
            SQLiteDataAdapter adp = new SQLiteDataAdapter("select * from tb_IO where ID=" + sett.Pr_id + " and case_id=" + sett.case_id, cn);
            adp.Fill(dt);
          
           
            Genflaw_report cryRpt = new Genflaw_report();
            BillPath = BillPath + "\\CrystalReport1.rpt";
            cryRpt.Load(BillPath);
            cryRpt.Database.Tables[0].SetDataSource(dt);
            
            cryRpt.Refresh();
            crystalReportViewer1.ReportSource = cryRpt;
            crystalReportViewer1.Refresh();
            
        }
Posted

 
Share this answer
 
Table's name from report & DataTable's name from code should be the same. So your code(declaration) should be like below
C#
DataTable dt = new DataTable("tb_IO");//tb_IO is Table from your SQL query.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900