السلام عليكم
1-am working on Desk top app using vs 2008 with sql server 2008 i want to enter 3 parameters (string + 2 dates) from text boxes to crystal report
eg. enter Project name and StartDate range to get project data
i wrote this code ( 3 parameters ) but it did not get any data
but 2 parameters (Name and StartDate ) works good
ReportDocument report= new ReportDocument();
cryRpt.Load(@"..\..\CrystalReport1.rpt");
ParameterFieldDefinitions crParameterFieldDefinitions;
ParameterFieldDefinition crParameterFieldDefinition;
ParameterValues crParameterValues = new ParameterValues();
ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
// 1st param project Name
crParameterDiscreteValue.Value = textBox1.Text;
crParameterFieldDefinitions = report.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["Name"]; // from formula field
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Clear();
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
// 2nd param start date
crParameterDiscreteValue.Value = textBox2.Text;
crParameterFieldDefinitions = report.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["dateRange"]; // from formula field
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
// 3rd param end date
crParameterDiscreteValue.Value = textBox3.Text;
crParameterFieldDefinitions = report.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["dateRange"];
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
crystalReportViewer1.ReportSource = report;
crystalReportViewer1.Refresh();
formula:
{Projects.ProjName}={?Name}
and
{Projects.StartDate} in {?dateRange}
2-is there a solution to pass textboxes params to sql query and get data directly like this link(i faced a prob. when fill data set when i wrote params which is { the column 'HR' not found } )
http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-sql-query.htm
any one could help me in any prob.
Best regards,
Ehab Mohamed
__._,_.___
Kindly visit my Blog http://amrsaafan.blogspot.com
MARKETPLACE
.
__,_._,___
0 comments:
Post a Comment