Skip to Content
May 02, 2019 at 10:08 AM

Get SQL query from report using C# at runtime


I want to get Report SQL query to apply on my Dataset with more filter applied.

Currently I've report with SQL query like (I can show from Visual Studio -> Show SQL query)
I've two CSV with inner join applied on dataset.

SELECT DISTINCT `my_csv`.`RUNDE`, `my_csv`.`JAHR`, `my_csv`.`PRUEFUNGSORT` FROM `eteiln.csv` `my_csv` INNER JOIN `esp.csv` `anotehr_csv` ON (`my_csv`.`JAHR`=`anotehr_csv`.`JAHR`) AND (`my_csv`.`RUNDE`=`anotehr_csv`.`RUNDE`)
 WHERE  `my_csv`.`ZULASSUNG`='J' AND `my_csv`.`RUECKTRITT` IS  NULL  AND `my_csv`.`bachelor_jn`='n'

Apart from above query I've custom `WHERE` condition with my WPF application.

I am getting few part of query from report "myReportDocument.DataDefinition.RecordSelectionFormula"

Is there any way to get full SQL query and I can also add/edit where condition by parsing query string?

I've already tried rptClientDoc.RowsetController.GetSQLStatement

but it throws error a even rptClientDoc.DatabaseController.CanExecuteSQL() returns false.