on 05-09-2014 5:26 AM
Hi,
We have been working on Crystal Reports(using Interop.CRAXDRT.dll V11.5.0). For some reason we need to replace the ReportObjects(FieldObjects, TextObject etc) from reports. We are successfully able to replace the field objects from main report, however if we try to delete the field objects from subreport we were getting access violation exception,
For generating subreport object we had written following code.
foreach (Section section in objRpt.Sections)
{
foreach (var rptObjects in section.ReportObjects)
{
var subReportObj = rptObjects as SubreportObject;
if (subReportObj == null) continue;
var subReport = objRpt.OpenSubreport(subReportObj.SubreportName);
subReport.Database.LogOnServerEx("crdb_ado.dll", _mSDsn, "", _mSUid, _mSPwd, "OLE DB", _sConnectString);
//Traverse the report and collect the field objects to delete.
}
}
And following is the code to delete the field object.
var rptSection = objReport.Sections.Cast<Section>().FirstOrDefault(section => section.Name.Equals("DetailsSection1", System.StringComparison.OrdinalIgnoreCase));
if(rptSection ==null) return;
var oldFieldObject = rptSection.ReportObjects.OfType<FieldObject>().FirstOrDefault(fieldObj =>(fieldObj.Field is DatabaseFieldDefinition) && fieldObj.Name.Equals("Email1",System.StringComparison.OrdinalIgnoreCase));
if (oldFieldObject == null) return;
rptSection.DeleteObject(oldFieldObject);
and last line of above code is giving following error.
As CR XI R2 is no longer supported I moved your post to the SAP Crystal Reports - Legacy SDKs SCN Space.
Please see if this KBA will help:
And the Developer Help file for CR XI R2 is here:
Developer Library XI Release 2 Productivity Pack
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow us on Twitter
Message was edited by: Ludek Uher
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.