Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, i have try to bind Crystal with using Datatable

My Code:

C#
cnn.Open();
            DataTable dt1 = new DataTable();
            dt1 = Dt_Args("select EmpNameC  from  ShiftTable where dated'01/Oct/2014'and empcodeC='18'"); // Dt_Args method to execute datatable

            DataSet ds = new DataSet();
            ds.Tables.Add(dt1);
           
            objRpt.SetDataSource(ds);
            crystalReportViewer1.ReportSource = objRpt;
            crystalReportViewer1.Refresh();


it run without any issue but not showing in crystal report.
Posted
Updated 16-Oct-14 22:56pm
v2

1 solution

Can you try with this
C#
ReportDocument rptDoc = new ReportDocument();
rptDoc.Load(Server.MapPath("CrystalReportTest.rpt"));
rptDoc.SetDataSource(ds.Tables["YourTable"]);
crystalReportViewer1.ReportSource = rptDoc;
crystalReportViewer1.Refresh();
 
Share this answer
 
Comments
prasanna.raj 17-Oct-14 5:49am    
Still not showing to crystal Rpt

cnn.Open();
DataTable dt1 = new DataTable();
dt1 = Dt_Args("select EmpNameC from ShiftTable where dated = '01/Oct/2014'and empcodeC='18'"); // Dt_Args method to execute datatable
DataSet ds = new DataSet();
ds.Tables.Add(dt1);
rptDoc.Load(@"E:\Prasanna\WindowsApplication\DynamicCrys_SAMPLE\DynamicCrys_SAMPLE\CrystalReport1.rpt");
rptDoc.SetDataSource(ds.Tables["ShiftTable"]);
crystalReportViewer1.ReportSource = rptDoc;
crystalReportViewer1.Refresh();
NaibedyaKar 17-Oct-14 8:15am    
Did you add the fields on the report viewer?
prasanna.raj 18-Oct-14 1:54am    
Yes i Added..
NaibedyaKar 18-Oct-14 2:02am    
Hmm, ok. Did you check the data in the table is coming fine?

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