public void RunReport(string outputFile, int cc, int yr, int wk)
{
ReportDocument rd = new ReportDocument();
rd.Load(FullFilePath("myreport.rpt"));
rd.Refresh();
rd.SetDatabaseLogon("userid", "password");
foreach (Table tbl in rd.Database.Tables)
{
tbl.LogOnInfo.ConnectionInfo.ServerName = "dbname";
tbl.LogOnInfo.ConnectionInfo.DatabaseName = "";
tbl.LogOnInfo.ConnectionInfo.UserID = "userid";
tbl.LogOnInfo.ConnectionInfo.Password = "password";
}
foreach (IConnectionInfo ci in rd.DataSourceConnections)
{
ci.SetLogon("userid", "password");
}
DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
ExportOptions CrExportOptions;
PdfRtfWordFormatOptions pdfFormatOptions = new PdfRtfWordFormatOptions();
CrDiskFileDestinationOptions.DiskFileName = outputFile;
CrExportOptions = rd.ExportOptions;
{
CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
CrExportOptions.FormatOptions = pdfFormatOptions;
}
SetCurrentValuesForParameterField(rd, "IP_COMP_CODE", cc);
SetCurrentValuesForParameterField(rd, "IP_YEAR", yr);
SetCurrentValuesForParameterField(rd, "IP_WEEK", wk);
rd.Export();
}
Obviously I've changed the names of the userid, password, database and report.
So, as I said, the first time I do the export it fails. If I ignore the exception and run the export again, it'll work just fine and it'll continue to work fine. I can run reports until I stop the app (an ASP.NET MVC application)
I've tried different formats as well, specifically, CSV and XLS. No matter which I do first, I'll get the out of memory the first time I export and then it'll work fine. So, for example, I could export as PDF, it will fail, and then export in XLS and it'll work. If I do XLS first, it'll fail, but then whatever I do after will work fine. So the problem doesn't appear to be specific to the export format.
I am using CRforVS_redist_install_64bit_13_0_4.zip
I'm running Windows 7 64-bit.
Thanks for any insight you can provide.