views:

9

answers:

1

I created a dataset (.xsd) from a stored procedure which takes 2 parameters. The .xsd file is linked to a crystal report. When I load the report no data is displayed. Also I dont want the user to be prompted for the parameters as I know the values in code depending on page that requested the report load. How do I link the parameters to the report datasource?

A: 

Using XSD to build crystal reports is called Push Model.
In this case you use XSD file to bind report fields. Here is a sample code for binding report datasource and set its parameters,

...
ReportDocument rptDoc = new ReportDocument();
rptDoc.Load(Server.MapPath("ETR0040.rpt"));

DataSet dsResult = DBGateway.ExecuteCommand('command');
rptDoc.SetDataSource(dsResult);

// Report parameters.
rptDoc.SetParameterValue("CustomerCode", customerCode);
rptDoc.SetParameterValue("CurrentDate", DateTime.Today);
...

rptViewer.ReportSource = rptDoc;

Also, you can use rptDoc to export report itself to PDF or Excel.

Ahmed