Pushing Data/Passing Values to Crystal Reports from C#??

Ok, I'm having a very difficult time finding information on how to get
data from C# code into a Crystal Report. This is what I want to do:

I have a report that will list everything sold withing a certain
timeframe. No problems with that in Crystal Reports XI. However, I
want to be able to specify a single date value or a date range, and the
customer account number. I do not want to use Crystal Reports to
prompt the user for the data. I want to decide in my C# what the
select values will be and then use that data in the Crystal Report.
For Example:

WHAT I HAVE:

In the Crystal Report rpt file, I have a filter on date (give the sales
for only 1 day), and I group by the Account Number. This returns the
information for all accounts and what sales occurred for that account
on the specified day (that's either hard-coded in the report, or input
from a Crystal Report prompt to the user).


WHAT I WANT:

I want to be able to tell the report to return data for ONLY account
number 'X' and specify the date 'D'. The obvious thing I could do is
set up a parameter in the report to prompt the user for input. But I
don't want to do this; I want to send that data through C# and tell the
report what to use.

Is this possible Can anyone point me to a tutorial that will explain
how to do this I have been searching for over a week now and still
have not found anything helpful.

Thank you very much for any help!!!


Answer this question

Pushing Data/Passing Values to Crystal Reports from C#??

  • RobertSM

    hey,

    is this problem solved because i need it also so if you of anybody else can help me

    with best regards,

    jeroen


  • Luisgph

    One way I know of that you could do this is to create a strongly typed dataset with whatever tables & columns you need. When you create the report, simply select that ADO.NET dataset as the data source.

    In order to populate the dataset, you can, in whatever event is kicking off the report for you, can:

    Create a dataset object of that dataset, use the new row method of that dataset to create a new row, assign a value from you C# code to the appropriate row, then use the add row method of the dataset to add that row to the collection of rows in the dataset.

    Hope this helps.


  • Hash Govind

    You can use these parameters and set their values in code so that they do not prompt the end user to enter values. This can be done through your report document object.

    rpt.SetParameterValue("ParameterName", "ParameterValue");

    Hope this helps


  • Pushing Data/Passing Values to Crystal Reports from C#??