0

My problem is that I need Ad-Hoc reports with variable queries and variable content/columns/etc. customized and saved per user and I don't have a solution yet.

I have an MVC 4 C# application with a SQL Server database and I have SSRS available.

I'm looking at displaying reports using the visual studio report viewer.

This is a simple example of putting the reportViewer into an MVC application on a web forms page.

The report viewer can show different reports by changing the reportViewer's source dataset, ReportPath and ReportServerURL

In code, I see examples like this where I can override the dataset and path to the RDLC file, but what I would like to do is just pass a dynamically generated dataset and RDLC file to the viewer. This would give me the flexibility to build and save the user's report template in the database, and then just recall it and run the report.

Is this possible, or am I barking up the wrong tree?

rene
  • 41,474
  • 78
  • 114
  • 152
Brad Boyce
  • 1,248
  • 1
  • 17
  • 34

2 Answers2

0

I am shooting from the hip here and there is probably a better solution for this but essentially an ssrs report is an XML file,

I suspect you could generate this XML on the fly based on your criteria (lots of pain), save the file as as a temp.rdl or rdlc file (i forget which is for which) and then call it from your reportviewer control

or

if your users are responsible for building the report then the pain is non existent just read in the File generated by the report builder and save that to the database.

or

if you fancy using a report server, you can interface with the SSRSReportService web service, there are quite a few options to upload a report, assign permissions etc, hopefully you see where i am going with this.

hopefully one of those options helps you :)

Wombelite
  • 302
  • 1
  • 6
  • Thanks for taking the time to suggest. I've been redirected to try Stimulsoft reporting tool for MVC. I hesitate to mark this as an answer as I don't know which of these (if any) would work. If I get back to trying SSRS rdlc file approach, I will update this. – Brad Boyce Nov 21 '13 at 22:54
0

I actually do this in one of the projects I work on. I generate the xml on the fly and load it into a memorystream which I then load into the viewer. I also create the datasets and load those at the same time. There is a dynamic-rdlc-generation tag here on stackoverflow that may have some interesting questions/answers to look through as well.

//GenerateRdl returns memory stream of dynamically constructed xml
MemoryStream report = GenerateRdl(rep.fields, selected);
//rvMain is my report viewer on the page            
rvMain.LocalReport.LoadReportDefinition(report);

//this is the main dataset for the report.  I don't do any subreports
//for the reports I generate
ReportDataSource reportData = new
  ReportDataSource("ReportData", ds.Tables[0]);

//I use this for the company logo I'm placing at the top of each report
ReportDataSource logo = new ReportDataSource("LogoDS", GetLogoDataSet().Tables[0]);

rvMain.LocalReport.DataSources.Clear();

rvMain.LocalReport.DataSources.Add(reportData);
rvMain.LocalReport.DataSources.Add(logo);
rvMain.LocalReport.Refresh();
Glen
  • 334
  • 2
  • 10