Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I simply write a SQL query to get the records from database and it will shows on crystal report..
My code is :-
C#
adpt = new OleDbDataAdapter("SELECT TOP 10 slsmName, SUM(NetAmt) AS TotalAmount FROM salesDetails WHERE slsDate BETWEEN #" + MF.retOriginalDate(DTP1.Value.ToShortDateString()) + "# AND #" + MF.retOriginalDate(DTP2.Value.ToShortDateString()) + "# GROUP BY slsmName ",DC.conn);
            
            TopSalesmanDataSet1 TSD = new TopSalesmanDataSet1();//TopSalesmanDataSet1 is a dataSet control
            adpt.Fill(TSD);            
            if (TSD.Tables[1].Rows.Count > 0)
            {                               
                TopSalesmanReport TSR = new TopSalesmanReport();
                TSR.SetDataSource(TSD.Tables[1]);
                MessageBox.Show(TSD.Tables[1].Rows.Count.ToString());//result is 2
                TSR.Refresh();
                report_show RS = new report_show();
                RS.crystalReportViewer1.ReportSource = TSR;
                RS.crystalReportViewer1.Refresh();
                RS.Show();
            }


problem is when I run this code, the query get records from database and its shown by message box. but on crystal report it doesn't appear.. I checked crystal report connection and design...

thanks in advanced....
Posted
Updated 28-Jun-13 3:50am
v2
Comments
[no name] 28-Jun-13 10:04am    
I do not pretend to be an expert but "RS.crystalReportViewer1.ReportSource = TSR;" does not look right to me. Maybe it is, I do not know.
JayantaChatterjee 28-Jun-13 10:22am    
TopSalesmanReport(TSR) is a crystal report,and report_show() is form name in which crystal report viewer exist...
so here I assign crystal_report to crystalReportViewer by ReportSource property...
[no name] 28-Jun-13 11:08am    
Ah got it. Thanks.
Mahesh Bailwal 28-Jun-13 10:32am    
First try with static report without any dynamic data. I mean report with some hard coded value. If its work then try again with SQL data.
JayantaChatterjee 28-Jun-13 11:11am    
@Mahesh I tried crystal report with direct database connection,Its fine shows all the records.
but when i tried with dynamic data which i posted, then it happened same result(No data on crystal reports)... :-(

1 solution

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