-
April 3rd, 2013, 11:38 AM
#1
c# and Crystal Reports with two parameters
hello everyone,
I keep trying to pass several parameters to a crystal report, and what happens is the default parameters of the result show instead of my entered parameters.
Has anyone else had this issue before?
Chris
My Code is Below:
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load("c:\reports\ReportName+".rpt");
ConnectionInfo c = new ConnectionInfo();
c.ServerName = GlobalStorage.Servername;
c.IntegratedSecurity = true;
c.DatabaseName = GlobalStorage.DatabaseName;
CrystalDecisions.CrystalReports.Engine.Tables CrTables = cryRpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
CrystalDecisions.Shared.TableLogOnInfo crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = c;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
int count = 0;
viewer.ReportSource = cryRpt;
viewer.Refresh();
ParameterFields pfields = new ParameterFields();
foreach (MyParameter p in parameters)
{
ParameterDiscreteValue crtParamDiscreteValue;
ParameterField crtParamField;
ParameterFields crtParamFields;
crtParamDiscreteValue = new ParameterDiscreteValue();
crtParamField = new ParameterField();
crtParamFields = new ParameterFields();
crtParamDiscreteValue.Value = p.parametervalue;
crtParamField.ParameterFieldName = p.parametername;
crtParamField.CurrentValues.Add(crtParamDiscreteValue);
crtParamFields.Add(crtParamField);
}
viewer.ParameterFieldInfo = pfields;
viewer.Refresh();
viewer.BringToFront();
viewer.Show();
-
April 3rd, 2013, 11:51 AM
#2
Re: c# and Crystal Reports with two parameters
i modified my code slightly:
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(@"c:\a1vcr\rs2k\reports\"+ReportName+".rpt");
ConnectionInfo c = new ConnectionInfo();
c.ServerName = GlobalStorage.Servername;
c.IntegratedSecurity = true;
c.DatabaseName = GlobalStorage.DatabaseName;
CrystalDecisions.CrystalReports.Engine.Tables CrTables = cryRpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
CrystalDecisions.Shared.TableLogOnInfo crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = c;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
int count = 0;
foreach (MyParameter p in parameters)
{
cryRpt.SetParameterValue(p.parametername, p.parametervalue);
}
viewer.ReportSource = cryRpt;
viewer.Refresh();
viewer.BringToFront();
viewer.Show();
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|