Refresh fields in datasource

Stimulsoft Reports.NET discussion
dlangford
Posts: 1
Joined: Wed Aug 06, 2014 1:22 am

Refresh fields in datasource

Post by dlangford »

Hi,

We're just evaluating your product, but can't figure out how to achieve this...

I have a report that is linked to a sql view, and want to add a field to the view then have it available in the report designer.

After adding a field to a view used in a report, I've tried opening the report, going to the Dictionary panel, then going Actions -> Syncronize...but the new field doesn't appear.

Hopefully there's a simple way for the designer to see the database changes...

Thanks in advance,
Dave.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Refresh fields in datasource

Post by Alex K. »

Hello, Dave

Please try to use the "RetrieveColumn" button in the edit datasource window for the necessary datasource.

Thank you.
petrdivis
Posts: 19
Joined: Thu Mar 23, 2017 7:05 am

Re: Refresh fields in datasource

Post by petrdivis »

Hi,
can this be achieved programatically when having custom StiUserSource and StiUserAdapterService? So the column appears in Dictionary on the right

thanks!
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Refresh fields in datasource

Post by Lech Kulikowski »

Hello,

You can use RegData() and Synchronize() methods.

Thank you.
petrdivis
Posts: 19
Joined: Thu Mar 23, 2017 7:05 am

Re: Refresh fields in datasource

Post by petrdivis »

Hello,
unfortunatelly, the RegData creates a new DataSource "test" instead of replacing our "GEONIS/test" datasource
GeonisReportDesigner_2019-07-15_15-34-53.png
GeonisReportDesigner_2019-07-15_15-34-53.png (4.29 KiB) Viewed 3046 times
the code:

Code: Select all

StiReport.Load(filePath);
UpdateAssemblies();

foreach (StiDataSource stiReportDataSource in StiReport.DataSources)
{
    if (stiReportDataSource.GetDataAdapter() is GReportAdapterService gds)
    {
        DataTable gDataTable = gds.FetchColumns(stiReportDataSource as GReportDataSource);
        StiReport.RegData(stiReportDataSource.Name, gDataTable);
    }
}

StiReport.Dictionary.Synchronize();
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Refresh fields in datasource

Post by Lech Kulikowski »

Hello,

You should use the same name of the DataSet(GEONIS) and Table(test) in the RegData() method.

Thank you.
petrdivis
Posts: 19
Joined: Thu Mar 23, 2017 7:05 am

Re: Refresh fields in datasource

Post by petrdivis »

Thanks, I tried as you suggested with
RegData("GEONIS", gDataTable) but it didnt refresh missing column.

the mrt looks like this:
Notepad2_2019-07-16_08-04-30.png
Notepad2_2019-07-16_08-04-30.png (51.2 KiB) Viewed 3036 times
I tried to delete DOCUMENT column from the DB, but in Dictionaries in Designer it does not refresh.
GeonisReportDesigner_2019-07-16_08-08-27.png
GeonisReportDesigner_2019-07-16_08-08-27.png (15.01 KiB) Viewed 3036 times
The "GEONIS" is category name in the GReportDataSource.

Code: Select all

public override string GetCategoryName()
{
    return "GEONIS";
}
Attachments
GeonisReportDesigner_2019-07-16_08-08-27.png
GeonisReportDesigner_2019-07-16_08-08-27.png (15.01 KiB) Viewed 3036 times
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Refresh fields in datasource

Post by Lech Kulikowski »

Hello,

Please check:
report.Dictionary.DataSources.Clear();
report.RegData("");
report.Dictionary.Synchronize();

Thank you.
petrdivis
Posts: 19
Joined: Thu Mar 23, 2017 7:05 am

Re: Refresh fields in datasource

Post by petrdivis »

That is weird, even if i do
report.Dictionary.DataSources.Clear();
report.Dictionary.Synchronize();

the Data Sources in Dictionary UI does not get empty.
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Refresh fields in datasource

Post by Lech Kulikowski »

Hello,

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

Thank you.
Post Reply