Click here to Skip to main content
13,143,774 members (38,219 online)
Rate this:
Please Sign up or sign in to vote.
See more: , +
I deployed a 2008 application which uses crystal reports 2008 to a network server. I use the setup to install the application on the client computer. When they run the application and try to view a report with the reportviewer, the error "load report failed" appears. The application searches for the report in a local folder of the user but they are not there. If I put them there manually the application works fine.
What do I need to do to get the reports installed automatically when I run the setup?
Posted 8-Apr-11 9:15am
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

"Load Report Failed"

This error occurs by following scenarios.

Invalid File path
Invalid File name

So make sure your report files are exists in right path.

BTW for Setup creation with Crystal Report, try below one.

How to Crystal Report Merge Module[^]

How to deploy Crystal Report[^]
janmas 9-Apr-11 2:40am
Hello Thatraja,
the application can't find the reports because they are not on the location where the application is going to search for them after installation: C:\Documents and Settings\Administrator\Local Settings\Apps\2.0\L9XBKHGJ.QQ4\X5DONZVZ.5G6\decl..tion_0000000000000000_0001.0000_e8bb3bc73c7ac69d.
When i put the reports there manually it works fine. What do i need to do to get the reports in my setup, i am using the publish option in
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This is not really an answer to your question, but consider putting those reports on the server. That way anyone can access the same reports and if you (or the client) ever delete, change or add one you don't have to repeat it for every user.
How to automatically install them on a users computer I do not know, but I think you add an installer project (which I suppose you already have) and add a custom Installer Class in the application that you want to install. There you could write a section which copies the reports from your install folder to the users machine. In the installer project you assign the Installer Class as a custom action.
Good luck!
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

By default they are set not to copy to the output directory.

In your solution right click on the crystal reports -> properties.

Change Do not copy property to

Copy always or Copy if newer
janmas 9-Apr-11 2:36am
Hello Simon,

Í have changed the property to "Copy Always" and deployed the project and run setup but still get the same message. The application searches for the reports in: "C:\Documents and Settings\Administrator\Local Settings\Apps\2.0\L9XBKHGJ.QQ4\X5DONZVZ.5G6\decl..tion_0000000000000000_0001.0000_e8bb3bc73c7ac69d" but the reports are not there.
Simon_Whale 9-Apr-11 4:54am
how are you calling them in your code?
janmas 10-Apr-11 2:23am
Hello Simon,

I use this code:
Code to set the application path:
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
sPath = System.IO.Path.GetDirectoryName(sPath)
If sPath.EndsWith("\bin") Then
sPath = sPath.Substring(0, Len(sPath) - 4)
End If
End Sub

Code to select the report, set the selection and call the reportviewer:
Private Sub btnKladdeclaratie_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKladdeclaratie.Click
selection = Nothing
For Each dataGridViewRow As DataGridViewRow In dgWerkzaamheden.SelectedRows
If CBool(dgWerkzaamheden.SelectedRows(0).Cells("Gefiatteerd").Value) = False Then
Continue For
selection = selection & "{Moon_Werkzaamheden.werkzaamhedenid}=" & CInt(dataGridViewRow.Cells("WerkzaamhedenId").Value) & " OR "
End If

If Val(Len(selection)) > 0 Then
selection = "(" & Mid(selection, 1, Len(selection) - 4) & ")"
selection = selection
Dim objForm As New ReportViewer
objForm.ViewReport(sPath & "\Reports\Declaratie_Zaak.rpt", selection, )
End If
End Sub

Code to view the report:
Friend Function ViewReport(ByVal sReportName As String, Optional ByVal sSelectionFormula As String = "", Optional ByVal param As String = "") As Boolean
'Declaring variablesables
Dim intCounter As Integer
Dim intCounter1 As Integer

'Crystal Report's report document object
Dim objReport As New _

'object of table Log on info of Crystal report
Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo

'Parameter value object of crystal report
' parameters used for adding the value to parameter.
Dim paraValue As New CrystalDecisions.Shared.ParameterDiscreteValue

'Current parameter value object(collection) of crystal report parameters.
Dim currValue As CrystalDecisions.Shared.ParameterValues

'Sub report object of crystal report.
Dim mySubReportObject As _

'Sub report document of crystal report.
Dim mySubRepDoc As New _

Dim strParValPair() As String
Dim strVal() As String
Dim index As Integer


'Load the report

'Check if there are parameters or not in report.
intCounter = objReport.DataDefinition.ParameterFields.Count

'As parameter fields collection also picks the selection
' formula which is not the parameter
' so if total parameter count is 1 then we check whether
' its a parameter or selection formula.

If intCounter = 1 Then
If InStr(objReport.DataDefinition.ParameterFields(0).ParameterFieldName, ".", CompareMethod.Text) > 0 Then
intCounter = 0
End If
End If

'If there are parameters in report and
'user has passed them then split the
'parameter string and Apply the values
'to their concurrent parameters.

If intCounter > 0 And Trim(param) <> "" Then
strParValPair = param.Split(CChar("&"))

For index = 0 To UBound(strParValPair)
If InStr(strParValPair(index), "=") > 0 Then
strVal = strParValPair(index).Split(CChar("="))
paraValue.Value = strVal(1)
currValue = objReport.DataDefinition.ParameterFields(strVal(0)
Rate this: bad
Please Sign up or sign in to vote.

Solution 4


*****************************************CRYSTAL REPORT GENERATION************************************

Dim MyConString As String = "DRIVER={MySQL ODBC 5.1 Driver};" & _
"SERVER=localhost;" & _
"DATABASE=timeclock;" & _
"UID=root;" & _
"PASSWORD=itdept;" & _

MsgBox("Connection is opened")

Dim myReport As New ReportDocument
Dim myData As New DataSet

Dim myAdapter As New Odbc.OdbcDataAdapter
Dim MyConnection As New Odbc.OdbcConnection(MyConString)
Dim MyCommand As New Odbc.OdbcCommand

'select all from employee table
MyCommand.CommandText = "SELECT * From employee"

MyCommand.Connection = MyConnection
myAdapter.SelectCommand = MyCommand
myAdapter.Fill(myData) 'fill data and load report
myReport.Load("C:\Documents and Settings\mbather\Desktop\TimeMan\TimeMan\TimeMan\Reports\CrystalReport1.rpt")
CrystalReportViewer1.ReportSource = myReport

Catch ex As Exception
MessageBox.Show(ex.Message, "Report could not be created", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
'close connection

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170915.1 | Last Updated 3 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100