Crystal Reports
- Hi guys, i insert to my project a crystal report a dataset and i want to run a query to my database next store the result to dataset and next pass the result to the crystal report, so i am using this code:
As you can see in the code my crystal report name is crystalreportviewer1 my dataset name is dataset1, my database name is data_5.mdb. In my dataset1 i had datatable named datatable1 and inserted 5 columns (column1, column2, ....column5).CrystalReport1 objReport = new CrystalReport1(); string sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|data_5.mdb"; string sQuerySelect = "SELECT ID, name, surname, moneyperhour, telephone FROM employee"; System.Data.OleDb.OleDbDataAdapter dAdapterSelect = new System.Data.OleDb.OleDbDataAdapter(sQuerySelect, sConnectionString); System.Data.OleDb.OleDbCommandBuilder cBuilderSelect = new System.Data.OleDb.OleDbCommandBuilder(dAdapterSelect); DataSet1 ds = new DataSet1(); dAdapterSelect.Fill(ds, "employee"); objReport.SetDataSource(ds.Tables[1]);<br/> crystalReportViewer1.ReportSource = objReport;<br/> crystalReportViewer1.Refresh();<br/>
What i am trying to do, is to run a query and pass the result to crystal report, but the above code cant show the data from the query, it only shows (in the crystal report viewer)the current date (upper left) and the page number(down right).
Any ideas?- Changed TypeHarry ZhuMSFT, ModeratorThursday, November 05, 2009 2:37 AM
All Replies
- Hi,
Please make sure the dataset have data in it.
Have you drag field of the dataset onto crystal report?
You might want to walk through the tutorial about connecting to dataset:
http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/en/CrystalReports_dotNET_SDK/crsdk_net_doc/doc/crsdk_net_doc/html/crtsktutorialsdatads.htm
Harry
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. - First of all thank you for replying me. Yes i have tested the dataset because i have a datagridview in my form which has as data source my dataset.
- Hi,
If the dataset has data in it . You might want to try the working simplified project here:
http://cid-219dc49fbdfffbd1.skydrive.live.com/self.aspx/Public/crystal%20report%20push%20test.rar
I saw you use objReport.SetDataSource(ds.Tables[1]);
This table may do not contain the required data.
Please try to set ds as the datasource :
objReport.SetDataSource(ds);
Harry
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. - Hi,
A long shot, but make sure the report itself doesn't have any 'filters' on the data. If the report contains a filter (or whatever Crystal calls them now), it could be the filter is 'filtering out' every row in the data set causing nothing to be shown.
Also, in my outdated and somewhat limited experience, Crystal filters are much, much slower than using Sql where's and joins appropriately, so my advice would be to avoid them where possible and provide only the correct data to the report in the first place.
Of course, none of that applies if you have no filters anyway... We are changing the issue type to “General Discussion” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by opening the Options list at the top of the post window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.


