cancel
Showing results for 
Search instead for 
Did you mean: 

Subreport prompts login password in CrystalReportViewer

Former Member
0 Kudos

Hi,

We have Visual Studio 2010 with CrystalReport 13 Dev version. We would like to save a report with data and view it in a CrystalReportViewer for WPF in a separate session. The database connection is set within a program to a different server/database to all connections in the report and its subreports. It is fine if a report does not contain any subreport. But if a report has a subreport, it always prompt for a login password. The code is below:

-- in one program:

ReportDocument report = new ReportDocument();

report.Load(@"C:\TEMP\CASReport.rpt");

report.Refresh();

for (int i = 0; i < report.DataSourceConnections.Count; i++)

report.DataSourceConnections<i>.SetConnection(@"SHOJIK\MSSQLSERVERR2", "DEVDB", "dbo", "123");

foreach (ReportDocument subreport in report.Subreports)

for (int i = 0; i < subreport.DataSourceConnections.Count; i++)

subreport.DataSourceConnections<i>.SetConnection(@"SHOJIK\MSSQLSERVERR2", "DEVDB", "dbo", "123");

report.SaveAs(@"C:\TEMP\report.rpt", true);

report.Close();

-- in another program::

ReportDocument report = new ReportDocument();

report.Load(@"C:\TEMP\report.rpt");

this.ReportViewer.ViewerCore.ReportSource = report;

and the login prompt shows up. What can I do to remove the login prompt?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Never mind. I found it. If I use ExportToDisk() it worked.

report.ExportToDisk(ExportFormatType.CrystalReport, @"C:\TEMP\report.rpt");

Thanks!

Answers (0)