d0fefc6e23caa07601ecddd03cecaf15caebd79c
FAQ/Questions/Dynamically-Changing-Data-Sources.md
| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | +#Dynamically Changing Data Sources |
|
| 2 | + |
|
| 3 | +[[_TOC_]] |
|
| 4 | + |
|
| 5 | +##Question |
|
| 6 | + |
|
| 7 | +How can I change the data source I'm using for my reports on the fly? |
|
| 8 | + |
|
| 9 | +##Answer |
|
| 10 | + |
|
| 11 | +You can change the data source for individual reports by overriding the [[PreExecuteReportSet|/FAQ/PreExecuteReportSet]] method. Here is the source code for changing data sources: |
|
| 12 | + |
|
| 13 | +``` |
|
| 14 | +public override void PreExecuteReportSet(Izenda.AdHoc.ReportSet reportSet) |
|
| 15 | +{ |
|
| 16 | + base.PreExecuteReportSet(reportSet); |
|
| 17 | + string orig = reportSet.Source; |
|
| 18 | + string target = "[dbo].[Orders2]"; |
|
| 19 | + |
|
| 20 | + if(!orig.Contains("Orders")) { |
|
| 21 | + return; //check for strings like "Orders". If that's not found, we return. |
|
| 22 | + } |
|
| 23 | + foreach (JoinedTable jt in reportSet.JoinedTables) |
|
| 24 | + { |
|
| 25 | + jt.TableName = jt.TableName.Replace(orig, target); |
|
| 26 | + } |
|
| 27 | + foreach (Report r in reportSet.Reports.AllValues) |
|
| 28 | + { |
|
| 29 | + foreach (Field f in r.Fields) |
|
| 30 | + { |
|
| 31 | + f.ColumnName = f.ColumnName.Replace(orig, target); |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + foreach (Filter f in reportSet.Filters) |
|
| 36 | + { |
|
| 37 | + f.Column = f.Column.Replace(orig, target); |
|
| 38 | + } |
|
| 39 | +} |
|
| 40 | +``` |
|
| ... | ... | \ No newline at end of file |
FAQ/UserGuides/15.3-Advanced-Expressions.md
| ... | ... | @@ -1,40 +0,0 @@ |
| 1 | -#Dynamically Changing Data Sources |
|
| 2 | - |
|
| 3 | -[[_TOC_]] |
|
| 4 | - |
|
| 5 | -##Question |
|
| 6 | - |
|
| 7 | -How can I change the data source I'm using for my reports on the fly? |
|
| 8 | - |
|
| 9 | -##Answer |
|
| 10 | - |
|
| 11 | -You can change the data source for individual reports by overriding the [[PreExecuteReportSet|/FAQ/PreExecuteReportSet]] method. Here is the source code for changing data sources: |
|
| 12 | - |
|
| 13 | -``` |
|
| 14 | -public override void PreExecuteReportSet(Izenda.AdHoc.ReportSet reportSet) |
|
| 15 | -{ |
|
| 16 | - base.PreExecuteReportSet(reportSet); |
|
| 17 | - string orig = reportSet.Source; |
|
| 18 | - string target = "[dbo].[Orders2]"; |
|
| 19 | - |
|
| 20 | - if(!orig.Contains("Orders")) { |
|
| 21 | - return; //check for strings like "Orders". If that's not found, we return. |
|
| 22 | - } |
|
| 23 | - foreach (JoinedTable jt in reportSet.JoinedTables) |
|
| 24 | - { |
|
| 25 | - jt.TableName = jt.TableName.Replace(orig, target); |
|
| 26 | - } |
|
| 27 | - foreach (Report r in reportSet.Reports.AllValues) |
|
| 28 | - { |
|
| 29 | - foreach (Field f in r.Fields) |
|
| 30 | - { |
|
| 31 | - f.ColumnName = f.ColumnName.Replace(orig, target); |
|
| 32 | - } |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - foreach (Filter f in reportSet.Filters) |
|
| 36 | - { |
|
| 37 | - f.Column = f.Column.Replace(orig, target); |
|
| 38 | - } |
|
| 39 | -} |
|
| 40 | -``` |
|
| ... | ... | \ No newline at end of file |