Problem with Datarelation by code

Stimulsoft Reports.NET discussion
Post Reply
Stephan1
Posts: 122
Joined: Fri Aug 31, 2007 7:22 am
Location: Germany

Problem with Datarelation by code

Post by Stephan1 »

Hi there,

i have a problem setting a datarelation of the report by code. Problem is, when i open the Report with m_Stireport1.Design the Datarelation is not shown at my datasources.

Here is the example.

m_StiReport = New Stimulsoft.Report.StiReport
m_StiReport.Load(path)
Dim o As Object = m_StiReport.Dictionary.Relations.Clone()

m_StiReport.Dictionary.Databases.Clear()
m_StiReport.Dictionary.DataSources.Clear()
m_StiReport.Dictionary.Relations.Clear()

m_StiReport.RegData(m_Dataset)
m_StiReport.Dictionary.Synchronize()

m_StiReport.Dictionary.Relations = DirectCast(o, Stimulsoft.Report.Dictionary.StiDataRelationsCollection)
m_StiReport.Dictionary.RegRelations()
m_StiReport.Design()

Do i have to start "m_StiReport.Dictionary.Synchronize()" before setting the relation or after that ?.

Thx for your help.

Stephan


Edit:

I checked the code in the designer and i found that the relation is in the code. But it's not visible at my Datasources.

Private Sub InitializeComponent()
Me.WaWi_VKBelegePositionen = New WaWi_VKBelegePositionenDataSource
Me.WaWi_VKBelegeSeriennummern = New WaWi_VKBelegeSeriennummernDataSource
Me.ParentBelPoszuSrn = New Stimulsoft.Report.Dictionary.StiDataRelation("BelPoszuSrn", "BelPoszuSrn", "BelPoszuSrn", Me.WaWi_VKBelegePositionen, Me.WaWi_VKBelegeSeriennummern, New System.String() {"ID"}, New System.String() {"BelegPosID"})




Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Problem with Datarelation by code

Post by Edward »

Hi Stephan,

The typical code for creation relations from code looks like follows:

Code: Select all

StiReport report = new StiReport();
report.Load("D:\\relations.mrt");
DataSet ds = new DataSet("Demo");
ds.ReadXml("D:\\demo.xml");
report.RegData(ds);
report.Dictionary.Synchronize();
StiDataRelation dataRelation = new StiDataRelation("MyRelation", report.Dictionary.DataSources["Categories"], report.Dictionary.DataSources["Products"], new System.String[]{"CategoryID"}, new System.String[] {"CategoryID"});
report.Dictionary.RegRelations();
report.Dictionary.Relations.Add(dataRelation);
Please also check that there is no relations with repeated names in your report.

Thank you.
Stephan1
Posts: 122
Joined: Fri Aug 31, 2007 7:22 am
Location: Germany

Problem with Datarelation by code

Post by Stephan1 »

Thx Edward,

but for what use is then

Dim o As Object = m_StiReport.Dictionary.Relations.Clone()
m_StiReport.Dictionary.Relations = DirectCast(o, Stimulsoft.Report.Dictionary.StiDataRelationsCollection)

I thougt this is a way to set the Relation as it is set in my report.

Thx
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Problem with Datarelation by code

Post by Edward »

Hi Stephan,

You are welcome. Please follow the example and relations will be easily registered!

Thank you.
Post Reply