【问题标题】:Error Opening Crystal Report in ASP.NET在 ASP.NET 中打开 Crystal Report 时出错
【发布时间】:2013-10-28 05:54:17
【问题描述】:

我试图在我的网站上打开一个水晶报告,但它给出了一个错误 这是我尝试过的代码

 protected void report_view(object sender, EventArgs e)
   {
    ReportDocument cryRpt = new ReportDocument();
    TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
    TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
    ConnectionInfo crConnectionInfo = new ConnectionInfo();
    Tables CrTables;

    cryRpt.Load("C:\\Report1.rpt");

    crConnectionInfo.ServerName = "local";
    crConnectionInfo.DatabaseName = "MyEmployees";
    crConnectionInfo.UserID = "MYLAPTOP\\HOME";

    CrTables = cryRpt.Database.Tables;
    foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
    {
        crtableLogoninfo = CrTable.LogOnInfo;
        crtableLogoninfo.ConnectionInfo = crConnectionInfo;
        CrTable.ApplyLogOnInfo(crtableLogoninfo);
    }

    CrystalReportViewer1.ReportSource = cryRpt;
    CrystalReportViewer1.RefreshReport();
    }

这是 CrystalReportViwer 中显示的错误

  Failed to open the connection. Failed to open the connection. Report1 {1222DD0B-C24E-  4E66-8EE1-7ED7F5F0D6B4}.rpt

我正在使用带有 Crystal Reports 11 的 Visual Studio 2010

【问题讨论】:

    标签: crystal-reports crystal-reports-xi


    【解决方案1】:

    您在声明连接详细信息时似乎缺少密码。尝试添加它:

    crConnectionInfo.ServerName = "local";
    crConnectionInfo.DatabaseName = "MyEmployees";
    crConnectionInfo.UserID = "MYLAPTOP\\HOME";
    crConnectionInfo.Password = "Password"; //Swap with real password of course
    

    确保所有文件路径和文件名也正确。

    您也可以查看SetDataBaseLogon() method

    【讨论】:

    • 数据库没有密码保护。 . .
    • 我个人怀疑服务器名称,数据库是本地的,所以我将服务器名称设置为本地,与 SqlServer 中的用户ID 相同,也与 SqlServer 中的用户名相同
    • SetDataBaseLogon() 方法对我有用,谢谢@Conrad Lotz
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多