Talk with the Author
 Crystal Reports Forum : General Information : Talk with the Author
Message Icon Topic: Crystal Reports Application Post Reply Post New Topic
Author Message
chitemerere
Newbie
Newbie
Avatar

Joined: 04 Jul 2008
Location: Zimbabwe
Online Status: Offline
Posts: 29
Quote chitemerere Replybullet Topic: Crystal Reports Application
    Posted: 06 Jul 2008 at 1:54pm

I am new to programming.  I am writing an application in Visual Basic using Visual Studio 2008.  I am trying to create an embedded crystal report within a project which will be used by my main application as an .exe program.  My simple code for this embedded report is as follows:

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

Public Class Form1

Private TypeIIDMFsReport As ReportDocument

Private Sub ConfigureCrystalReports()

TypeIIDMFsReport = New ReportDocument

Dim reportPath As String = Application.StartupPath _

& "\" & "TypeIIDMFsReport.rpt"

TypeIIDMFsReport.Load(reportPath)

myCrystalReportViewer.ReportSource = TypeIIDMFsReport

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

ConfigureCrystalReports()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

ConfigureCrystalReports()

End Sub

End Class

I tested the application by putting the report in the bin\debug folder, running it and works well
 
The build action property of the report has been set to embedded resource.  I have added a setup project for the windows application which i then built.  However, i am getting a report load exception, specified file cannot be located.  I thought that at compile time, the report is copied to the same folder as my application's .exe file?
 
Can someone please assist me with what i need to do to resolve this exception.
 
Many thanks and kind regards.
Chris
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 08 Jul 2008 at 8:26pm
I think there is a little confusion on what an embedded report is. When you create a Windows application with a Crystal Reports, it embeds the report binary into the application and create a class that represents the report. You can then declare a variable of this class name, instantiate it, and assign it to the viewer.

However, looking at your code I see that you are using the Load() method and referencing the report via its fully qualified filename. This is the non-embedded method of loading a report. (As a side note, this is the only way of loading a report that is supported by ASP.NET). However, Windows apps do allow it.

So if you want to use the report class, declare and instantiate a report object and use it. Then you don't have to worry about your setup.exe file. On the other hand, if you want to call the Load() method, then you need to manually add the report to your setup project and specify the location to install it.

If you are new to Crystal Reports, I have complete coverage with sample code of using embedded and non-embedded reports in my books. You can find out more about my books at Amazon.com or reading the Crystal Reports eBooks online.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
chitemerere
Newbie
Newbie
Avatar

Joined: 04 Jul 2008
Location: Zimbabwe
Online Status: Offline
Posts: 29
Quote chitemerere Replybullet Posted: 09 Jul 2008 at 12:27am
Dear Brian
 
Many thanks for your reply.  I was indeed confused with the embedded and non-embedded report issue.  However, after some further reading, I managed to sort out the problem by using the non-embedded route and calling the report through a specific file path.
 
I will definitely buy one of your books on Crystal Reports.
 
Many thanks and kind regards.
Chris
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.014 seconds.