how to pass parameters to stored procedure from crystal reports de开发者_如何学JAVAsigner and in code also ??
If you use required stored procedure as source for report, while building report itself, you can pass stored procedure parameters from code as the following;
ReportDocument rptDocument = new ReportDocument();
// Load report.
rptDocument.Load(Server.MapPath("rptFileNameOrPath"));
ParameterFields parameterFields = new ParameterFields();
ParameterField parameterField = null;
ParameterDiscreteValue parameterValue = null;
parameterField = new ParameterField();
parameterValue = new ParameterDiscreteValue();
parameterField.Name = "@ContactId";
parameterValue.Value = "1";
parameterField.CurrentValues.Add(parameterValue);
parameterFields.Add(parameterField);
this.rptDocument.SetParameterValue("@ContactId", parameterValue);
@ContactId:
is a parameter for required stored procedure.
Finally, you can either export report or print it based on your requirements.
// 0, 0: to print all the pages.
this.rptDocument.PrintToPrinter(1, false, 0, 0);
Regarding Crystal Report Designer, you just use View Report option, you will be asked to enter values for all report parameters, just enter required values.
精彩评论