2
votes

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

2
If you have the opportunity to use any other reporting tool, I urge you to do so. CR on asp.net = extreme pain. But that error means an instance of Crp_Cust_suratHesb cannot be created. What is that? Did you forget to deploy a dll to the server?Crowcoder

2 Answers

1
votes

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("","","","")
0
votes

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