Ask a questionAsk a question
 

General DiscussionCrystal Reports

  • Wednesday, October 28, 2009 11:57 PMlepass_7 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    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:
    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/>
    
    
    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).
    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?

All Replies

  • Friday, October 30, 2009 2:53 AMHarry ZhuMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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.
  • Friday, October 30, 2009 4:56 PMlepass_7 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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.
  • Monday, November 02, 2009 2:08 AMHarry ZhuMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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.
  • Monday, November 02, 2009 2:31 AMYort Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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...
  • Thursday, November 05, 2009 2:36 AMHarry ZhuMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    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.