我正在使用 Visual Studio 2010 Ultimate Edition 并且我已经安装了 SAP Crystal Reports 的 Beta 2 版本,Visual Studio 2010 版本。一切正常,但是当我尝试为 CrystalReportViewer 设置 ReportSource 属性时我找不到它。有没有其他方法可以将水晶报表绑定到 CrystalReportViewer?这是我的来源:
var cryRpt = new ReportDocument();
cryRpt.Load("~/CrystalReports/DateToDateReport.rpt");
new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo;
var crConnectionInfo = new ConnectionInfo();
var crParameterDiscreteValue = new ParameterDiscreteValue {Value = dtpFromDate.Value};
ParameterFieldDefinitions crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
ParameterFieldDefinition crParameterFieldDefinition = crParameterFieldDefinitions["fromDate"];
ParameterValues crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Clear();
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
crParameterDiscreteValue.Value = dtpToDate.Value;
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["toDate"];
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
crConnectionInfo.ServerName = "ServerName";
crConnectionInfo.DatabaseName = "Database";
crConnectionInfo.UserID = "Username";
crConnectionInfo.Password = "Password";
var crTables = cryRpt.Database.Tables;
foreach (Table crTable in crTables)
{
crtableLogoninfo = crTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crtableLogoninfo);
}
crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();