0

我正在使用 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(); 
4

2 回答 2

1

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

于 2014-09-26T18:46:17.900 回答
0

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

于 2010-09-24T12:32:37.597 回答