找不到crystalReportViewer.ReportSource

时间:2010-09-17 16:58:02

标签: c# crystal-reports crystal-reports-xi

我正在使用Visual Studio 2010旗舰版,我已经安装了SAP Crystal Reports的Beta 2版本,Visual Studio 2010的版本。一切正常但是当我尝试为crystalReportViewer设置ReportSource属性时我不能找到它。有没有其他方法将Crystal报表绑定到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(); 

2 个答案:

答案 0 :(得分:0)

您必须设置.NET FRAMEWORK 4.0 - > 3.5

答案 1 :(得分:0)

实际上是`crystalReportViewer1。 ViewerCore .ReportSource = cryRpt; 1