【问题标题】:How to manually add connection info to a cystal report in c#?如何在 C# 中手动将连接信息添加到水晶报表?
【发布时间】:2013-02-06 20:17:53
【问题描述】:

我有一个包含水晶报表查看器的表单,并且我有一个水晶报表。水晶报表没有数据连接,没有数据源,因为我已经手动连接到我的数据库。 (通过为所有内容编写代码) 我想在我的报告中显示数据。如何将报告的连接信息设置为表单中的连接信息。 IE。 myDataset、myCon 等。

P.S:我对 Crystal Reports 非常陌生。我查看了教程,但使用水晶报表向导进行连接。

谢谢

【问题讨论】:

    标签: c# crystal-reports


    【解决方案1】:

    我将连接字符串放在 Configuration.AppSettings 中。

    CrystalReportSource CrystalReportSource1 = new CrystalReportSource();
    CrystalReportViewer CrystalReportViewer1 = new CrystalReportViewer();
    
    CrystalReportViewer1.ReportSource = CrystalReportSource1;
    CrystalReportViewer1.EnableParameterPrompt = false;
    CrystalReportSource1.Report.FileName = "Report3.rpt";
    CrystalReportSource1.EnableCaching = false;
    
    CrystalReportSource1.ReportDocument.SetParameterValue(0, ponumber);
    CrystalReportSource1.ReportDocument.SetParameterValue(1, receiptno);
    
    
    
    TableLogOnInfo logOnInfo = new TableLogOnInfo();
    
    logOnInfo.ConnectionInfo.ServerName = ConfigurationManager.AppSettings["WarehouseReportServerName"];
    logOnInfo.ConnectionInfo.DatabaseName = ConfigurationManager.AppSettings["WarehouseReportDatabaseName"];
    logOnInfo.ConnectionInfo.UserID = ConfigurationManager.AppSettings["WarehouseReportUserID"];
    logOnInfo.ConnectionInfo.Password = ConfigurationManager.AppSettings["WarehouseReportPassword"];
    
    TableLogOnInfos infos = new TableLogOnInfos();
    infos.Add(logOnInfo);
    CrystalReportViewer1.LogOnInfo = infos;
    
    maindiv.Controls.Add(CrystalReportSource1);
    maindiv.Controls.Add(CrystalReportViewer1);
    
    
    CrystalReportViewer1.DataBind();
    

    【讨论】:

    • 我在CrystalReports下的intellisense中没有CrystalReportSource???
    • 使用 CrystalDecisions.Shared;使用 CrystalDecisions.CrystalReports.Engine;使用 CrystalDecisions.Web; (您可能需要安装 Crystal 运行时)
    猜你喜欢
    • 2015-03-03
    • 2010-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多