Very often our customers are concerned with the question of passing the ConnectionString parameters to a report programmatically from within the application. We hope this article can answer the question under discussion and make the work with our reporting component much more convenient.
Here are the basic steps a report maker should perform:
1) Create an empty .rst template file
2) Add a data source to the report manually with the help of Document Data Source Editor
And fill in the required data to create the initial connection string
3) The next step is to create a report parameter that would handle the ConnectionString.
4) After this we should open the GenerateScript property of the Document to write down the script that would handle our data source and match it against the ConnectionString parameter.
The following code was used in our sample:
5) After this, we set the path to our report template inside the application
6) And finally, we are able to modify the connection string parameter we created previously in our report by specifying the required data inside the application with the help of the following code:
In order to avoid any issues you should check to make sure the code is put before the lines initiating document rendering.
The sample WPF application used in this article is attached under the link below.
WpfApplication12.zip