I am trying to change the connection string of a UriReportSource at runtime in an MVC 4 application. I am using this page as a guide:
http://www.telerik.com/support/kb/reporting/details/changing-the-connection-string-dynamically-according-to-runtime-data
However I end up getting this error: "Unable to get report parameters: Missing report name"
Here is the ReportsController:
Code for the controller for the view containing the ReportViewer:
(Note that ReportModel.TheReport is of type InstanceReport)
And the View:
I have verified that passing the reportviewer is working when simply passing the report in as a Uri, but we have to be able to change the connection string dynamically because or data/connections are tenant-based.
Any help is appreciated
http://www.telerik.com/support/kb/reporting/details/changing-the-connection-string-dynamically-according-to-runtime-data
However I end up getting this error: "Unable to get report parameters: Missing report name"
Here is the ReportsController:
public class ReportsController : ReportsControllerBase{ protected override IReportResolver CreateReportResolver() { var reportsPath = HttpContext.Current.Server.MapPath("~/Reports"); return new ReportFileResolver(reportsPath) .AddFallbackResolver(new ReportTypeResolver()); //return new CustomReportResolver(); } protected override ICache CreateCache() { return Telerik.Reporting.Services.Engine.CacheFactory.CreateFileCache(); }}Code for the controller for the view containing the ReportViewer:
public ActionResult Index(){ string connectionString = GetConnectionString(); ReportConnectionStringManager connStringManager = new ReportConnectionStringManager(connectionString); string uri = Server.MapPath("/Reports/Tickets2.trdx"); UriReportSource theReport = new UriReportSource() { Uri = uri }; InstanceReportSource fixedReport = connStringManager.UpdateReportSource(theReport); return View(new ReportModel() { TheReport = fixedReport });}And the View:
@model FastTrack.MVC.Models.ReportModel@{ ViewBag.Title = "Reports";}@section styles{ <link href="ReportViewer/styles/telerikReportViewer-8.1.14.618.css" rel="stylesheet" /><style> #reportViewer1 { position: relative; width: 100%; height: 1000px; font-family: 'segoe ui', 'ms sans serif'; overflow: hidden; } </style> <link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">}@section scripts{ <script src="ReportViewer/js/telerikReportViewer-8.1.14.618.js"></script>}<div class="container"><div class="row"> @(Html.TelerikReporting().ReportViewer() .Id("reportViewer1") .ServiceUrl("/api/reports/") .TemplateUrl("/ReportViewer/templates/telerikReportViewerTemplate-8.1.14.618.html") .ReportSource(@Model.TheReport) .ViewMode(ViewModes.INTERACTIVE) .ScaleMode(ScaleModes.SPECIFIC) .Scale(1.0) .PersistSession(false) ) </div> </div>I have verified that passing the reportviewer is working when simply passing the report in as a Uri, but we have to be able to change the connection string dynamically because or data/connections are tenant-based.
Any help is appreciated