This is the first time I am doing this.
I have built a software. I will be using a setup package from Visual Studio. I think I will be using the Setup Project which Builds an installer for a Windows-based application as my project has been built on Window Forms. I have included Crystal Reports. As it current stands I have method in my application when a user clicks on the button the reports is displayed. In that method the .rpt file path is showing as....
cryRpt.Load("C:\\MyFolder\\MyFolder\\ProjectName\\FolderName\\HRMS\\HRMS\\Report.rpt"); // this is from my PC.
So my question is what do I need to know to setup the correct .rpt file path. where ever it is going to be installed?
For clarification I need to install Crystal Reports on Clients PC? http://downloads.businessobjects.com/akdlm/cr4vs2010/CRforVS_13_0.exe
because I looked at this thread... here
Do I need to do anything else on Client's PC?
I am not sure if I am going to run into a problem related to this thread here I have hard code the path, any advice?
Thank you in advance if anyone can help me here.
using CrystalDecisions.CrystalReports.Engine;
private void btnReportA_Click_1(object sender, EventArgs e)
{
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load("C:\\MyFolder\\MyFolder\\ProjectName\\FolderName\\HRMS\\HRMS\\Report.rpt");
crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();
}
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
myCon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\MyFolder\MyFolder\ProjectName\FolderName\database.mdb");
crystalReportViewer1.Refresh();
}
update 1 with a solution-ish
I was looked at crystal reports dynamic path and I changed from the line of code from...
cryRpt.Load("C:\\MyFolder\\MyFolder\\ProjectName\\FolderName\\HRMS\\HRMS\\Report.rpt");
to
cryRpt.Load(Application.StartupPath + "\\Report.rpt");
Then move the rpt files in bin\Debug
You can find your bin/Debug file location by using the following code...
TextBox1.Text = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly
().Location);
Which I got from this website.
I think the above is a solution.
I will give an update 2 whenever I discovered how to use the Setup Project with Crystal Reports because I may or may not need to update on client's PC.
It took few hours to figure this out.
Update 2 I will open a new thread. I think update 1 is not really a solution.
You could always add the report to your project and then reference it like "~\Report.rpt"
.
As far as deploying the runtime, read this wiki from SAP on runtime deployment.