使用Crystal Reports在网站中加载报告失败

时间:2014-10-16 07:13:59

标签: asp.net vb.net iis crystal-reports iis-7.5

我开发了一个网站,我在我的网站上放了一些* .rpt文件。我在部署机器上使用Crystal Report运行时引擎(版本13.0.0.99)。这有Windows Server 2008 R2企业版。

然后,当我将应用程序添加到IIS并浏览它时,我收到错误"加载报告失败"即使是没有使用Crystal报表的网页也没有显示任何内容。报告的名称或* .rpt文件在每次刷新时都会更改,并且所有报告名称都会显示出来,并且错误页面上有多行包括奇怪的字符。

以下是错误页面的屏幕截图:

enter image description here

编辑1:

检查Temp文件夹的权限后,现在网站正常运行,但包含Crystal Report查看器的页面除外。我收到以下错误:

NewError

2 个答案:

答案 0 :(得分:1)

我认为你可以通过不同的方式使用它。

首先创建报告文档的实例,然后尝试通过加载功能映射报告 如下面给出的例子 -

Imports CrystalDecisions.CrystalReports.Engine

Dim reportdocument As New ReportDocument()
reportdocument.Load(Server.MapPath("CrystalReport.rpt"))
reportdocument.SetDatabaseLogon("","","","")

答案 1 :(得分:0)

尝试:

Imports CrystalDecisions
Imports CrystalDecisions.CrystalReports
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Dim RptDoc As New ReportDocument()
Dim crConnectionInfo As New ConnectionInfo
Dim CrTables As Tables
Dim CrTable As Table
Dim crtableLogoninfo As New TableLogOnInfo

RptDoc.Load(Server.MapPath(Request.ApplicationPath + "/Reports/myReport.rpt"))

With crConnectionInfo
    .ServerName = "myServer"
    .DatabaseName = "myDatabase"
    .UserID = "myUserID"
    .Password = "myPassword"
End With

CrTables = RptDoc.Database.Tables

For Each CrTable In CrTables
    crtableLogoninfo = CrTable.LogOnInfo
    crtableLogoninfo.ConnectionInfo = crConnectionInfo
    CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next 

RptDoc.SetDatabaseLogon(crConnectionInfo.UserID, crConnectionInfo.Password, crConnectionInfo.ServerName, crConnectionInfo.ServerName)

RptDoc.SetParameterValue("@myParameter", myValue)

Dim stream As New BinaryReader(RptDoc.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat))

Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", Convert.ToString("attachment; filename=") & myDownloadAsFilename)
Response.AddHeader("content-length", stream.BaseStream.Length.ToString())
Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)))
Response.Flush()
Response.Close()