Two Relations with the same name in datasource

Stimulsoft Reports.Web discussion
Post Reply
thomasRi
Posts: 5
Joined: Fri Sep 24, 2021 11:40 am

Two Relations with the same name in datasource

Post by thomasRi »

Hello, I'm using a DataSet as source for the report.
The DataSet has a few relations, but all with diferent names. But in the datasource in report two relations have the same name. (Name in datasource is different, but not the name). This causes an error in the viewer. How can I influence this? Where does this name came from?
My designer version isr 2021.3.4
Thanks in advance
Attachments
Screenshot_2.png
Screenshot_2.png (41.21 KiB) Viewed 336 times
Lech Kulikowski
Posts: 4066
Joined: Tue Mar 20, 2018 5:34 am

Re: Two Relations with the same name in datasource

Post by Lech Kulikowski »

Hello,

Please clarify how do you add these relations?

Thank you.
thomasRi
Posts: 5
Joined: Fri Sep 24, 2021 11:40 am

Re: Two Relations with the same name in datasource

Post by thomasRi »

Hi, thats the code how I add the relation. The name of the relation is always different to the others. I've tried variants without exception, but the behavior is the same. The property "Name in datasource" is in both relation correct, but not the property "Name is the same.
Thanks Thomas


DataRelation relation =
new DataRelation(
ownTableName + "_" + atrDescr.OwnPropertyName + "_" + otherTableName,
parentColumn,
childColumn, false);
try
{
// if (reportDataSet.Relations.Contains(relation.RelationName) == false)
reportDataSet.Relations.Add(relation);
}
catch (Exception)
{
try
{
// this can be happen if 2 relations to the same type are defined, for instance visit <-> person
string ownPropName = atrDescr.OwnPropertyName;
relation.RelationName = ownTableName + "_" + ownPropName + "_" +
childColumn.ColumnName;
// if (reportDataSet.Relations.Contains(relation.RelationName) == false)
reportDataSet.Relations.Add(relation); // log message if something went wrong !
}
catch (Exception ex1)
{
Log.Debug("Can't create relation \"" + relation.RelationName + "\"in report data set", ex1);
}
Lech Kulikowski
Posts: 4066
Joined: Tue Mar 20, 2018 5:34 am

Re: Two Relations with the same name in datasource

Post by Lech Kulikowski »

Hello,

Please send us a sample project that reproduces the issue for analysis.

Thank you.
thomasRi
Posts: 5
Joined: Fri Sep 24, 2021 11:40 am

Re: Two Relations with the same name in datasource

Post by thomasRi »

Hi, I'll do it, but it is complicated to make a project wich is intepentend for our database an for other projects.
Perhaps this information will help.
Both of those relations are between the same two tables, but the property is different.(this is needed because of the internal structure)
If I do the same thing windowsDesigner, not the webDesigner, ist works as expectet (see att., Name and Name in Datasource are identical.
Perhaps this will help
Thanks Thomas
Attachments
Screenshot_3.png
Screenshot_3.png (25.1 KiB) Viewed 224 times
Lech Kulikowski
Posts: 4066
Joined: Tue Mar 20, 2018 5:34 am

Re: Two Relations with the same name in datasource

Post by Lech Kulikowski »

Hello,

It is difficult to say something without a sample.

Thank you.
thomasRi
Posts: 5
Joined: Fri Sep 24, 2021 11:40 am

Re: Two Relations with the same name in datasource

Post by thomasRi »

Hi again, sorry for the delay
If you start the attached sample project you can see the double names in the datasource, as shown in the earlier posted screenshot. (Screenshot_2.png)
The solution is based on the sample on your webpage.
Thanks in advance
Thomas
Lech Kulikowski
Posts: 4066
Joined: Tue Mar 20, 2018 5:34 am

Re: Two Relations with the same name in datasource

Post by Lech Kulikowski »

Hello,

There are no projects in attachments.

Thank you.
thomasRi
Posts: 5
Joined: Fri Sep 24, 2021 11:40 am

Re: Two Relations with the same name in datasource

Post by thomasRi »

But now, I think
Attachments
IF_SampleDatasource.zip
(21.62 MiB) Downloaded 1 time
Post Reply