I have a report that has several SqlDataSources. Viewing the Report XML, the markup looks like the following:
<?xml version="1.0" encoding="utf-8"?><Report DataSourceName="This is my report" Width="10.0000012715658in" Name="Detailed Report" xmlns="http://schemas.telerik.com/reporting/2012/4.2"> <DataSources> <SqlDataSource QueryDesignerState="null" ConnectionString="connection_string_here" ProviderName="System.Data.OracleClient" SelectCommand="select statement goes here" Name="a name goes here1"> <Parameters> <SqlDataSourceParameter DbType="String" Name="Work_Week" /> <SqlDataSourceParameter DbType="String" Name="name" /> </Parameters> </SqlDataSource> <SqlDataSource QueryDesignerState="null" ConnectionString="connection_string_here" ProviderName="System.Data.OracleClient" SelectCommand="select statement goes here" Name="a name goes here2" /> <SqlDataSource QueryDesignerState="null" ConnectionString="connection_string_here" ProviderName="System.Data.OracleClient" SelectCommand="select statement goes here" Name="a name goes here3" /> </DataSources> <Items> </Items> <PageSettings PaperKind="Letter" Landscape="True" ColumnCount="1" ColumnSpacing="0in" ContinuousPaper="False"> </PageSettings> <StyleSheet> <Filters> </Filters> <Sortings> </Sortings> <Groups> </Groups></Report>
The problem is when I am try to use this code to change the connection string, it only appears to change the string for the <Report> tag. The 3 SqlDataSources appear to be private members of the object when I look at it while debugging and those connection strings are not modified by the code. I need those modified by code. The only way I have found to do this is to treat the XML as regular XML and replace those node's attributes with the proper strings instead of using the Telerik class properties/methods. This doesn't seem right, so I assume there is a way to set these connection strings properly.