Hi,
I've got report using connection string stored in Setting.settings. But I have to have ability to change connection string at runtime. Is it posiible ?
Please check this thread. Our 12.1 release will provide a better version for accomplishing it.
Regards,
Andres
Thanks. That almost what I've been looking for. But if I'm not wrong every time I add some new report I've got to regenerate DS Provider ? My goal is to change only connection string in whole reports. Unfortunately I can't change Connection String in Settings.settings - it's read only.... Do you see some solution ?
regards
Do you need to have different connection strings for different users? If so, you need to use the approach described in the other thread. In theory, the T4 template will be run automatically each time a .igr file is modified, but I had not verified it. If that does not work, you'll need to run it manually or you'll need to include a msbuild task to run it. This won't be necessary in 12.1.
If you need the change the connection string for all reports, you can set it in web/app.config.
it works ! Thanky you. But I'm curious about one thing. There is <SqlDataSource ConnectionName="xxxSqlDataSource1" ConnectionLocation="AppSettings" Name="xxxSqlDataSource1"> record in my report file. Can I change ConnectionLocation="AppSettings" value to some else ? If yes, what opportunities have I ?
thank you
If that XML file is not app.config, then you'll need to use the approach with the T4 template described in the post.
You don't need to change every report. You need to make sure the T4 template is run after you change the data source of any report in the project.
You basically need to add the .tt file in this .zip file to the solution and change the line in the .tt that says
using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["<#= project.Properties.Item("DefaultNamespace").Value + ".Properties.Settings." + dataSource.ConnectionStringKey #>"].ConnectionString))
to something like:
using (var con = new SqlConnection(MyCodeToGetTheConnectionString()))
and add that "MyCodeToGetTheConnectionString" function o the .tt file.
Then the reports will invoke code that will be generated by that .tt file to get the data for the report, and they will use the connection string you've provided.
It's windows form application. The whole connection with database is based on one connectionstring which is read from some XML configuration file. My intention is to use this connection string also in whole reports. When I'll install application on another machine or move database to another server I'll only have to change one XML file. Now it seems that I have to also change every report. Am I right ?