user1831490
user1831490

Reputation:

Load report failed in web site using Crystal Reports

I have developed a website and I have put some *.rpt files in my website. I use the Crystal Report run time engine on the deployment machine (version 13.0.0.99). This has Windows Server 2008 R2 enterprise edition.

Then when I add the application to IIS and I browse it I receive the error "Load report Failed" and nothing shows up even the web pages which are not using Crystal report. The name of the report or the *.rpt file changes on each refresh and all the reports names will be shown up and there are multiple lines including strange characters on the error page.

Here is the screenshot of the error page:

enter image description here

Edit 1:

After checking the permission of Temp folder, now the website runs normally except the pages which include Crystal Report viewer. I receive the following error:

NewError

Upvotes: 2

Views: 2496

Answers (2)

Howard Rothenburg
Howard Rothenburg

Reputation: 1348

Try:

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()

Upvotes: 0

Shivam Bareria
Shivam Bareria

Reputation: 84

i think you can use it through different way.

First create instance of the Report Document and then Try mapping your report through load Function as per example given below-

Imports CrystalDecisions.CrystalReports.Engine

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

Upvotes: 1

Related Questions