Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
4.33/5 (3 votes)
I deployed a vb.net 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

"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[^]
 
Share this answer
 
Comments
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 vs.net
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!
 
Share this answer
 
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
 
Share this answer
 
Comments
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)
MyBase.OnLoad(e)
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
Else
selection = selection & "{Moon_Werkzaamheden.werkzaamhedenid}=" & CInt(dataGridViewRow.Cells("WerkzaamhedenId").Value) & " OR "
End If
Next

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, )
objForm.Show()
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
'MsgBox(sReportName)
'Declaring variablesables
Dim intCounter As Integer
Dim intCounter1 As Integer

'Crystal Report's report document object
Dim objReport As New _
CrystalDecisions.CrystalReports.Engine.ReportDocument

'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 _
CrystalDecisions.CrystalReports.Engine.SubreportObject

'Sub report document of crystal report.
Dim mySubRepDoc As New _
CrystalDecisions.CrystalReports.Engine.ReportDocument

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

Try

'Load the report
objReport.Load(sReportName)

'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)
'MsgBox(paraValue.Value.ToString)
currValue = objReport.DataDefinition.ParameterFields(strVal(0)
THIS IS UR SOLUTION


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


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

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


Try
'MyConnection.Open()
MyConnection.Open()
'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")
myReport.Database.Tables(0).SetDataSource(myData.Tables(0))
CrystalReportViewer1.ReportSource = myReport

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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900