I know this question has been asked before, but I've been messing around for days and I've had no luck.
I'm using SQL server, .net and CR 8.5
I have a stored procedure that has 1 parameter (for simplicity), and I want to dynamically change this at run time.
I've got 1 form with a CR viewer, and I've added User.rpt to my project. I have found the following code on the web somewhere, but I'm still lost
If anyone can give me some code or advice - I'll be extremely gratefull
static public void AddCrystalParameter(CrystalDecisions.CrystalReports.Engine.ReportDocument crReport, string ParameterName, string ParameterValue)
{
ParameterFieldDefinitions crParameterFieldDefinitions = crReport.DataDefinition.ParameterFields;
ParameterValues crParameterValues = new ParameterValues();
ParameterFieldDefinition param = crParameterFieldDefinitions[ParameterName];
crParameterValues = param.CurrentValues;
ParameterDiscreteValue param_Val = new ParameterDiscreteValue();
param_Val.Value = ParameterValue;
crParameterValues.Add(param_Val);
param.ApplyCurrentValues(crParameterValues);
param.ApplyDefaultValues(crParameterValues);
}
private void cmdOk_Click(object sender, System.EventArgs e)
{
User ReportDoc;
ReportDoc = new User();
AddCrystalParameter(ReportDoc,"@EventID",txtParam.Text );
}
I'm using SQL server, .net and CR 8.5
I have a stored procedure that has 1 parameter (for simplicity), and I want to dynamically change this at run time.
I've got 1 form with a CR viewer, and I've added User.rpt to my project. I have found the following code on the web somewhere, but I'm still lost
If anyone can give me some code or advice - I'll be extremely gratefull
static public void AddCrystalParameter(CrystalDecisions.CrystalReports.Engine.ReportDocument crReport, string ParameterName, string ParameterValue)
{
ParameterFieldDefinitions crParameterFieldDefinitions = crReport.DataDefinition.ParameterFields;
ParameterValues crParameterValues = new ParameterValues();
ParameterFieldDefinition param = crParameterFieldDefinitions[ParameterName];
crParameterValues = param.CurrentValues;
ParameterDiscreteValue param_Val = new ParameterDiscreteValue();
param_Val.Value = ParameterValue;
crParameterValues.Add(param_Val);
param.ApplyCurrentValues(crParameterValues);
param.ApplyDefaultValues(crParameterValues);
}
private void cmdOk_Click(object sender, System.EventArgs e)
{
User ReportDoc;
ReportDoc = new User();
AddCrystalParameter(ReportDoc,"@EventID",txtParam.Text );
}