Skip to Content
Former Member
Oct 10, 2014 at 06:38 AM

Is it possible to update Datastructure definition programmatically?



I would like to add new database fields to the Database (DatabaseController) model, so that i can link them.

>I'm talking about the data definition of the report. I do not need to put database fields to the visual report.<

The aim is to bend existing Tablelinks to new fields, as underlying database structure has changed,

that affects the reports.

I'm using VS2013, and CR for VS v.

Here is a bit of code of what I'm trying to do...

private void AddMissingFields(CrystalDecisions.CrystalReports.Engine.ReportDocument Report)
            // local vars           
            CrystalDecisions.ReportAppServer.DataDefModel.Table ATable = null;
            //CrystalDecisions.ReportAppServer.DataDefModel.Field AField = null;
            FieldObject AField = null;

            // get report object from session or create a new report object
            CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument ReportClientDocument = Report.ReportClientDocument;
            CrystalDecisions.ReportAppServer.Controllers.DatabaseController dbController = ReportClientDocument.DatabaseController;

            ATable = (CrystalDecisions.ReportAppServer.DataDefModel.Table)dbController.Database.Tables.FindTableByAlias("SchuelerZeitraeume");

            if (ATable != null)
                // create field object
                AField = new FieldObject();   <-- HAS NO CONSTRUCTOR, ALSO ...DataFedModel.Field

                // fill field properties


The Problem is, that i can not find a possibility to create an field object. The Field Classes don't seem have an constructor or an method

that delivers me a new field object.

Here's an abstract example of two tables and what i want to achieve in it's linking in the reports.

(---> marks the linking)

Prechange datastructure, how it is now:

Table Left Table Right

-------------- ----------------

FieldX ---> FieldX

FieldY ---> FieldY

FieldZ ---> FieldZ

Postchange datastructure, how it should be then:

TableLeft TableRight

-------------- ----------------

ID ---> ID_OF_TableLeft

FieldX FieldX

FieldY FieldY

FieldZ FieldZ

1. New Fields ID and ID_OF_TableLeft in TableLeft and TableRight

2. Removing the Linking of the Fields X, Y and Z

3. Adding new Tablelink on the IDs

Thanks and regards

Antonio Cambule