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?