on ‎2023 Jul 20 7:07 PM
Hi, I'm seeing the issue described in https://answers.sap.com/questions/9760972/reportdocumentload-slow-due-to-saved-serverdatabas.html where simply calling Load() on a report file will attempt to connect to the database, before my app has a chance to change the tables' connection info to point to the correct place. The given solution is to turn off the various Verify report options, which is what I'd like to do. I have hundreds of reports though, so I'd like to automate that, rather than opening every report in the Crystal report designer and unchecking the box. The obvious method of calling Load(), setting EnableVerifyOnEveryPrint to false, then calling SaveAs() doesn't seem to work though 😞 But I found https://blogs.sap.com/2012/09/07/working-with-crystal-reports-report-options-through-crystal-reports... , which implies that it *should* work. This is what I'm doing:
CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rcd;
rd.Load(@"C:\temp\MyReport.rpt");
rcd = rd.ReportClientDocument;
CrystalDecisions.ReportAppServer.ReportDefModel.ReportOptions OReportOptions = rcd.ReportOptions;
OReportOptions.EnableVerifyOnEveryPrint = false;
rcd.SaveAs("MyReport_Updated.rpt", @"C:\temp");
But when I open MyReport_Updated.rpt, "Verify on First Refresh" is still checked.
Also, what's really strange is that I have two reports that both have "Verify on First Refresh" checked, but only one of them attempts to connect to the database on Load(). From what I read in the above forum post, I would have expected any report that has the Verify option to immediately connect to the DB, so why isn't it happening for one of the files?
And I think it would be nice to have an option for Load() to not attempt a DB connection; in my case, I know that the stored connection info is almost certainly wrong, and the first thing I do is to change it, but I have to Load the report before I can do that.
I'm running Crystal Reports for VS 13.0.33.4485.
Request clarification before answering.
Hi David,
CR for VS runtime is a bit tricky sometimes, depending one what you want to do, sometimes you can just make the change as you did and it takes when saved but the majority of those changes are only while the report is in scope.
Here's how to: Note: I have a check box to show the state of each but this does work
private void btnSetChanges_Click(object sender, EventArgs e)
{
CrystalDecisions.ReportAppServer.ReportDefModel.ReportOptions iro = rptClientDoc.ReportOptions;
CrystalDecisions.ReportAppServer.ReportDefModel.ReportOptions myRPTOpts = iro.Clone();
// SP 4 addition
myRPTOpts.ConvertNullFieldToDefault = checkBox3.Checked;
myRPTOpts.ConvertOtherNullsToDefault = checkBox17.Checked;
myRPTOpts.CanSelectDistinctRecords = checkBox1.Checked;
myRPTOpts.CanSetTableLocation = checkBox2.Checked;
myRPTOpts.DisplayGroupContentView = checkBox4.Checked;
myRPTOpts.EnableAsyncQuery = checkBox5.Checked;
myRPTOpts.EnablePushDownGroupBy = checkBox6.Checked;
myRPTOpts.EnableSaveDataWithReport = checkBox7.Checked;
myRPTOpts.EnableSaveSummariesWithReport = checkBox8.Checked;
myRPTOpts.EnableSelectDistinctRecords = checkBox9.Checked;
myRPTOpts.EnableTranslateDOSMemos = checkBox10.Checked;
myRPTOpts.EnableTranslateDOSStrings = checkBox11.Checked;
myRPTOpts.EnableUseCaseInsensitiveSQLData = checkBox12.Checked;
myRPTOpts.EnableUseDummyData = checkBox13.Checked;
myRPTOpts.EnableUseIndexForSpeed = checkBox14.Checked;
myRPTOpts.EnableVerifyOnEveryPrint = checkBox15.Checked;
myRPTOpts.ErrorOnMaxNumOfRecords = checkBox16.Checked;
// both routines below do not get saved - must be read only properties in the report or other methods to update them
if (cbConvertDateTimeType.SelectedItem.ToString() == "crConvertDateTimeTypeKeepDateTimeType")
{
myRPTOpts.ConvertDateTimeType = CrConvertDateTimeTypeEnum.crConvertDateTimeTypeKeepDateTimeType;
}
if (cbConvertDateTimeType.SelectedItem.ToString() == "crConvertDateTimeTypeKeepDateTimeType")
{
myRPTOpts.ConvertDateTimeType = CrConvertDateTimeTypeEnum.crConvertDateTimeTypeToDate;
}
if (cbConvertDateTimeType.SelectedItem.ToString() == "crConvertDateTimeTypeKeepDateTimeType")
{
myRPTOpts.ConvertDateTimeType = CrConvertDateTimeTypeEnum.crConvertDateTimeTypeToString;
}
if (cbPreferredView.SelectedItem.ToString() == "crReportDocumentCubeView")
{
myRPTOpts.PreferredView = CrReportDocumentViewEnum.crReportDocumentCubeView;
}
if (cbPreferredView.SelectedItem.ToString() == "crReportDocumentExcelView")
{
myRPTOpts.PreferredView = CrReportDocumentViewEnum.crReportDocumentExcelView;
}
if (cbPreferredView.SelectedItem.ToString() == "crReportDocumentQueryView")
{
myRPTOpts.PreferredView = CrReportDocumentViewEnum.crReportDocumentQueryView;
}
if (cbPreferredView.SelectedItem.ToString() == "crReportDocumentReportView")
{
myRPTOpts.PreferredView = CrReportDocumentViewEnum.crReportDocumentReportView;
}
//crMaxNumOfRecords.Text = myRPTOpts.MaxNumOfRecords.ToString();
//crNumOfBrowsingRecords.Text = myRPTOpts.NumOfBrowsingRecords.ToString();
//crNumOfCachedBatches.Text = myRPTOpts.NumOfCachedBatches.ToString();
//myRPTOpts.MaxNumOfRecords = Convert.ToInt16(crMaxNumOfRecords.Text);
//myRPTOpts.NumOfBrowsingRecords = Convert.ToUInt16(crNumOfBrowsingRecords.Text);
//myRPTOpts.NumOfCachedBatches = Convert.ToInt16(crNumOfCachedBatches.Text);
myRPTOpts.EnableVerifyOnEveryPrint = false;
rptClientDoc.ModifyReportOptions(myRPTOpts);
//CrystalDecisions.ReportAppServer.ReportDefModel.ReportOptions myRPTOpts;
//myRPTOpts = rptClientDoc.ReportOptions;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.