The Viewers do not have a property called ConnectionString and they will never have one. The Viewers' only job is to display a report, they do not need to "know" about connection strings. Imagine that you are exporting a report programmatically to PDF, let's say, then there is no Viewer at all. Where should the report get its data source from? Another example is binding a report to a Business Object -- the notion of connection string does not even exist in that case. In other words it is a responsibility of the Report instance to have a valid data source before it is ready for use, i.e. viewing, exporting, etc. And that can be achieved in numerous ways:
1. You can pass the connection string through your report's constructor, and then in the constructor, after the InitializeComponent() method call, replace the original connection string of your data source (i.e. SqlDataAdapter, etc.) with the passed in connection string.
2. You can create a property of your report called ConnectionString and in the setter do the same -- replace the original connection string of the DataSource with the new one.
3. You can directly type cast Report.DataSource to whatever your data source type is and then replace the connection string of that object before showing the report in the viewer.
There are probably lots of other ways to do that same thing. The main point is that you will not replace the Report.DataSource and thus keep your SQL. You will only replace connection string of the existing data source before you display the report.
I hope this helps.
the Telerik team
Check out Telerik Trainer
, the state of the art learning tool for Telerik products.