如何将参数传递给Visual Studio 2010的Crystal Report?看起来他们被忽略了
-
25-09-2019 - |
题
这在Visual Studio 2008中正常工作,但是由于我已切换到Visual Studio 2010和Visual Studio 2010的Crystal Reports,因此我的传递参数被忽略了。
他们在报告中显示,在选择公式方面只是忽略了!这是我用于创建报告和传递参数的代码。
private void Prepare()
{
var reportDocument = new ReportDocument();
string reportPath = string.Format(
"{0}\\{1}",
Globals.FormPath,
this.FormTemplate.Filename);
reportDocument.Load(reportPath);
ParameterDiscreteValue parameter;
foreach (var control in this.FormTemplateFieldControls)
{
switch (control.FormTemplateField.DataType)
{
case FormFieldDataType.Date:
this.AddParameterForDateTime(
reportDocument,
control.FormTemplateField.Name,
(DateTime)control.EditValue);
break;
case FormFieldDataType.DateTime:
this.AddParameterForDateTime(
reportDocument,
control.FormTemplateField.Name,
(DateTime)control.EditValue);
break;
case FormFieldDataType.Time:
this.AddParameterForDateTime(
reportDocument,
control.FormTemplateField.Name,
(DateTime)control.EditValue);
break;
case FormFieldDataType.Guid:
this.AddParameterForGuid(
reportDocument,
control.FormTemplateField.Name,
(Guid)control.EditValue);
break;
default:
this.AddParameterForString(
reportDocument,
control.FormTemplateField.Name,
control.EditValue.ToString());
break;
}
}
this.SetConnectionInfo(reportDocument);
var frm = new FormViewer();
frm.Report = reportDocument;
frm.ShowDialog();
frm.Dispose();
this.Close();
}
当我从设计师那里运行报告时,它可以正常工作。您可以看到参数正在传递,因为我在报告中显示它们。
对于我的报告,从存储过程中运行的参数似乎很好,只是由所有表组成的参数。
对于它的价值,这是我的选择公式:
{employee.HireDate} >= {?StartDate} And {employee.HireDate} <= {?EndDate}
解决方案
Visual Studio 2010的最新版本报告已解决。
其他提示
当您说“他们没有通过”时,会通过什么?他们是空白吗?
您可以自己查看参数,只是为了笑,尝试给他们一个不同的名字,这是一个额外的独特之处。其他一些报告设置或参数定义的方式可能会发生一些愚蠢的事情。
不隶属于 StackOverflow