cancel
Showing results for 
Search instead for 
Did you mean: 

.NET: Change Crystal Reports datasource in field explorer via XSD and XML

Former Member
0 Kudos

Hi there,

I am changing the datasource of a report during runtime. Afterwards, I would like to change the texts of the fields appearing in the field explorer.

I tried:

CrystalDecisions.ReportAppServer.DataDefModel.XMLDataSetClass xmlDS =

new CrystalDecisions.ReportAppServer.DataDefModel.XMLDataSetClass();

byte[] xmlContent = reportContent.getXmlContent();

byte[] xsdContent = reportContent.getXsdContent();

CrystalDecisions.ReportAppServer.CommonObjectModel.ByteArray xmlData =

new CrystalDecisions.ReportAppServer.CommonObjectModel.ByteArray();

CrystalDecisions.ReportAppServer.CommonObjectModel.ByteArray xsdData =

new CrystalDecisions.ReportAppServer.CommonObjectModel.ByteArray();

xmlData.ByteArray = xmlContent;

xmlDS.XMLData = xmlData;

xsdData.ByteArray = xsdContent;

xmlDS.XMLSchema = xsdData;

rasDoc.DatabaseController.SetDataSource(xmlDS, "", "");

rasDoc.Database.Tables[0].Description = "POMMES";

for (int i = 0; i < rasDoc.DatabaseController.Database.Tables[0].DataFields.Count; i++)

{

rasDoc.Database.Tables[0].DataFields<i>.Name = "TEST";

MessageBox.Show(rasDoc.Database.Tables[0].DataFields<i>.Name);

rasDoc.Database.Tables[0].DataFields<i>.HeadingText = "HOORAY";

rasDoc.Database.Tables[0].DataFields<i>.Description = "NOPE";

MessageBox.Show(rasDoc.Database.Tables[0].DataFields<i>.Description);

MessageBox.Show(rasDoc.Database.Tables[0].DataFields<i>.HeadingText);

}

When running this, the message boxes include the right strings I set before but when this is done, the filed explorer still shows no changes. What am I doing wrong??

Thanks,

Pascal

Accepted Solutions (1)

Accepted Solutions (1)

former_member208657
Active Contributor
0 Kudos

Simply changing the property won't work. RAS uses a Model-View-Controller architecture. You'll need to use the Controller to modify any aspect of the report.

I suggest you have a look at the links below. Make sure you are making a copy of your current table using the Clone method then use the Modify method to apply the changes to your report.

https://boc.sdn.sap.com/node/10445

https://boc.sdn.sap.com/node/10969

Answers (0)