Page 1 of 1

how to load tables when starting application

Posted: Fri Dec 18, 2020 10:41 pm
by rodrigo.santos
Hi guys, i'm learning to use stimulsoft, an information that i didn't quite understand, it was like loading the tables of a postgreeSQL connection. In other words, when starting the application it fetches from the database all the tables with their columns and having autorefresh. My application is ASP NET CORE. (My english not is so good)

//My code
public IActionResult GetReport()
{
StiReport report = new StiReport();
report.Dictionary.Databases.Add(new StiPostgreSQLDatabase("TMS", "User Id = user; Password = password; Host = localhost; Database = tms"));
return StiNetCoreDesigner.GetReportResult(this, report);
}

Not carry the tables
Not carry the tables
Capturar.PNG (3.62 KiB) Viewed 1688 times

Re: how to load tables when starting application

Posted: Mon Dec 21, 2020 7:50 pm
by Lech Kulikowski
Hello,

You should also add all data sources and columns.
Add DataSources:

Code: Select all

 StiSqlSource DS1 = new StiSqlSource("Connection", "DS1", "DS1", "SELECT * FROM DS1", true, false);
 report.Dictionary.DataSources.Add(DS1);
Add Columns:

Code: Select all

 foreach (DataColumn col in dataTableDS1.Columns)
 {
      DS1.Columns.Add(col.ColumnName, col.DataType);
 }
Thank you.

Re: how to load tables when starting application

Posted: Mon Dec 21, 2020 9:00 pm
by rodrigo.santos
Hi man,
I understood the logic to be implemented. but how do I select it to get all the tables from the database. In order to test I did the "Select * from Customers" but even so he does not create the columns. (use postgreSQL)


Thanks for your help.

Re: how to load tables when starting application

Posted: Tue Dec 22, 2020 3:12 pm
by HighAley
Hello,

If you are adding the data sources to the report with the external code, you should know the names of the tables.
There is no easy way to add the SQL data sources. You should add connection, SQL queries and all columns with your code.

Thank you.