cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid Report File Path Error

Former Member
0 Kudos

I have included several Crystal Reports as embedded resources in a Visual Studio 2010 C# project. When I try to run the application on a client PC I receive an invalid report file path error. Why am I receiving this error if the rpt is embedded in the manifest?

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor

The exact error would be nice to have.

Also, make sure there are read \ write rights on the c:\win\temp folder.

Web or Win app?

Ludek

Follow us on Twitter http://twitter.com/SAPCRNetSup

Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

Former Member
0 Kudos

The error message is "Invalid report file path."

There is no "c;\win\temp" folder but there is a "c:\windows\temp" folder and everyone has full rights.

It is a Windows application in C#.

Here is the code I have within the form I use to generate the report.

ReportDocument cryRpt = new ReportDocument();

TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();

TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();

ConnectionInfo crConnectionInfo = new ConnectionInfo();

Tables CrTables;

bool repeat = true;

while (repeat)

{

try

{

crConnectionInfo.ServerName = Properties.Settings.Default.CrystalServer;

crConnectionInfo.DatabaseName = Properties.Settings.Default.CrystalDatabase;

crConnectionInfo.IntegratedSecurity = true;

CrTables = cryRpt.Database.Tables;

foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)

{

crtableLogoninfo = CrTable.LogOnInfo;

crtableLogoninfo.ConnectionInfo = crConnectionInfo;

CrTable.ApplyLogOnInfo(crtableLogoninfo);

}

crystalReportViewer1.ReportSource = cryRpt;

crystalReportViewer1.Refresh();

}

catch (Exception exp)

{

MessageBox.Show(exp.Message);

DialogResult result1 = MessageBox.Show("Try Again?", "Database Connection Error",

MessageBoxButtons.RetryCancel);

if (result1 == DialogResult.Retry)

{

// Open form to update connection parameters

FormCrystalParms newWindow = new FormCrystalParms();

//this.Cursor = Cursors.WaitCursor;

newWindow.ShowDialog();

}

else

{

repeat = false;

}

}

former_member183750
Active Contributor
0 Kudos

In a nut shell, you have the following options to load and show a report:





Report Name (from string path)
                      CrystalReportViewer1.ReportSource == "C:\\Crystal\\crnet\\vbnet_win_simplepreviewreport\\World Sales  
                      Report.rpt"

By Report Object (from string path)
               
                   CrystalDecisions.CrystalReports.Engine.ReportDocument crReportDocument = new    
                   CrystalDecisions.CrystalReports.Engine.ReportDocument();
                   crReportDocument.Load("C:\\Crystal\\crnet\\vbnet_win_simplepreviewreport\\World Sales Report.rpt");

                'Bind the report to the viewer
                CrystalReportViewer1.ReportSource == crReportDocument


By Report Object (added to Project)
                'Bind a new instance of the strongly-typed report object to the viewer
                CrystalReportViewer1.ReportSource == new World_Sales_Report()



I see you declare the report document:

ReportDocument cryRpt = new ReportDocument();

but I do not see you set the actual report anywhere...(?).

- Ludek

Former Member
0 Kudos

I'm not sure I know what you mean. Don't these lines set the report?

crystalReportViewer1.ReportSource = cryRpt;

crystalReportViewer1.Refresh();

former_member183750
Active Contributor
0 Kudos

And what is cryRpt?

Perhaps it will help to have a look at the sample app vbnet_win_simplepreviewreport.zip which can be downloaded from here:

https://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsfor.NETSDK+Samples

- Ludek

Former Member
0 Kudos

cryRpt was declaared in the first line of my example.

ReportDocument cryRpt = new ReportDocument();

Former Member
0 Kudos

The following code now works on my development machine. It obtains the server name and database name from the configuration file. When I run on my client PC, however, it prompts me to log into the database. It provides the correct server name but the database name is blank and integrated security is not checked. The database name field is not enabled so I cannot provide a value.

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using CrystalDecisions.CrystalReports.Engine; //jp

using CrystalDecisions.Shared; //jp

namespace WindowsFormsApplication1

{

public partial class FormRptArtist : Form

{

private CrystalReport1 crReportDocument = new CrystalReport1();

public FormRptArtist()

{

InitializeComponent();

ToolTip toolTip = new ToolTip(); toolTip.SetToolTip(btnHelp, "Flash Video Training / Help");

helpProvider1.HelpNamespace = GlobalClass.gb_help;

}

private void FormRptArtist_Load(object sender, EventArgs e)

{

TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();

TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();

ConnectionInfo crConnectionInfo = new ConnectionInfo();

Tables CrTables;

bool repeat = true;

while (repeat)

{

try

{

crConnectionInfo.ServerName = Properties.Settings.Default.CrystalServer;

crConnectionInfo.DatabaseName = Properties.Settings.Default.CrystalDatabase;

crConnectionInfo.IntegratedSecurity = true;

CrTables = crReportDocument.Database.Tables;

foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)

{

crtableLogoninfo = CrTable.LogOnInfo;

crtableLogoninfo.ConnectionInfo = crConnectionInfo;

CrTable.ApplyLogOnInfo(crtableLogoninfo);

}

crystalReportViewer1.ReportSource = crReportDocument;

crystalReportViewer1.Refresh();

break;

}

catch (Exception exp)

{

MessageBox.Show(exp.Message);

DialogResult result1 = MessageBox.Show("Try Again?", "Database Connection Error",

MessageBoxButtons.RetryCancel);

if (result1 == DialogResult.Retry)

{

FormCrystalParms newWindow = new FormCrystalParms();

newWindow.ShowDialog();

}

else

{

repeat = false;

}

}

}

}

private void CrystalReport11_InitReport(object sender, EventArgs e)

{

}

private void btnHelp_Click(object sender, EventArgs e)

{

GlobalClass.displayflashhelp(this, "formrptartist");

}

private void crystalReportViewer1_Load(object sender, EventArgs e)

{

}

}

}

former_member183750
Active Contributor
0 Kudos

Check out this article:

[Troubleshooting Guide to Database Connectivity Issues with Crystal Reports in Visual Studio .NET Applications|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/b0225775-88c4-2c10-bd80-8298769293de]

- Ludek

Answers (0)