Crystal Report错误加载报告Asp.net应用程序失败

时间:2016-12-01 19:22:28

标签: c# asp.net asp.net-mvc reporting-services crystal-reports

我开发了一个Crystal Report门户网站,它正在使用其他报告,但我正在尝试托管一些报告,显示此错误"错误加载报告失败"。我不确定为什么会发生其他报道正在做同样的事情。请提出任何建议

var p = Request.QueryString["P"].ToString();
var appId = int.Parse(Request.QueryString["appId"].ToString());
var HE = new HIVAIDSEntities();
var app= HE.ApplicatioNames.FirstOrDefault(x => x.Hivrp_app_name_pk == appId);

//SQLReport report = new SQLReport();
var report = new ReportDocument();
//   Application.StartupPath 
report.Load(filename: Server.MapPath(p));
//Get SQL Server Details
string zServer = app.Hivrp_server_name;
string zDatabase = app.Hivrp_database_name;
string zUsername = app.Hivrp_user_id;
string zPassword = app.Hivrp_password;

var ciReportConnection = new ConnectionInfo
{
    ServerName = zServer,
    DatabaseName = zDatabase,
    UserID = zUsername,
    Password = zPassword
};

//Assign data source details to tables**

foreach (CrystalDecisions.CrystalReports.Engine.Table table in report.Database.Tables)
{
   table.LogOnInfo.ConnectionInfo = ciReportConnection;
   table.ApplyLogOnInfo(table.LogOnInfo);
}

//Assign data source details to the report viewer**
if (this.CrystalReportViewer1.LogOnInfo != null)
{
   TableLogOnInfos tlInfo = this.CrystalReportViewer1.LogOnInfo;
   foreach (TableLogOnInfo tbloginfo in tlInfo)
   {
       tbloginfo.ConnectionInfo = ciReportConnection;
   }
}
CrystalReportViewer1.ReportSource = report;
CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
CrystalReportViewer1.DisplayPage = true;
CrystalReportViewer1.RefreshReport();

0 个答案:

没有答案