简体   繁体   中英

Report viewer from SQL reporting services in VS 2008 report control

Report viewer from SQL reporting services in VS 2008 report control If I create a new report in VS 2008 they have a .rdlc extension and work correctly.

I have some reports that I was using in SQL reporting services. Extensions are .rdl and want to get them to work with VS 2008.

I copied the rdl files and the .rdl.data files over to VS 2008 (SP1) project but when I go to select the report in the control it does not see the file (I assume it is looking for a .rdlc file)

I tried rename the file to .rdlc and loaded the file up and got

The report definition has an invalid target namespace ' http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition ' which cannot be upgraded.

I see this http://social.msdn.microsoft.com/Forums/en-SG/vsreportcontrols/thread/65cefd7d-00d8-4be6-a53a-7e34dfd7eb2b

I see here http://www.gotreportviewer.com/ It says "RDL files are fully compatible with the ReportViewer control runtime. However, RDL files do not contain some information that the design-time of the ReportViewer control depends on for automatically generating data-binding code. By manually binding data, RDL files can be used in the ReportViewer control."

But the link for how to manual bind the data is broken.

Any ideas on how to manually rebind the data? Or a better way to get these reports to work with the 2008 control?

The server version *.rdl in SSRS 2008 is unfortunately not compatible with its local counterpart, the *.rdlc files.

Basically, all you can do is

  • either use the .RDL directly on the server (using "remote rendering" report in your ReportViewer control)

  • basically re-create the whole report as a local report from scratch

It's unbelievable - but unfortunately, it's the truth..... let's hope with .NET 4, Visual Studio 2010 it'll be better.

If you don't need advanced features like drill-down, and can't use VS2010, you can do this hack (that I do):

  • install new reportviewer.exe from VS2010 (beta2 or later I guess);
  • add Common/WebForms assemblies of the ReportViewer of version 10.0 to references;
  • manually parse RDL XML structure to get data source and/or query SQL (very easy);
  • use that to populate LocalReport.DataSource;
  • Do LocalReport.Render("PDF") to get PDF output (ActionResult code for generating PDF response is easy to find);
  • put a "View" button on the page and iframe;
  • "View" button (via JavaScript) will assign iframe src attribute to the url that returns the above PDF content - and it will give a nice PDF preview of the report inside the iframe;
  • alternatively, one can use jQuery Media plugin to render PDF object tag with same results;
  • additionally I parse RDL XML parameters and show them on page and pass them to the "generate report" url - I get my own nice UI controls for parameters as benefit;
  • additionally I have my own "export" buttons that calls LocalReport.Render(format) and provide output with correct MIME type (that's Excel, Word, PDF, and my manual CSV) - the export is improved in new version of the report viewer.

The above list may look scary but it took me only 2 days to hack the complete solution in ASP.NET MVC, and it's only ~300 lines of code, including my own CSV generation.

The code to bind data is very simple once you get DataTable/DataSet (from XML queries):

        var reportDataSource = new ReportDataSource();
        reportDataSource.Name = name;
        reportDataSource.Value = ds.Tables[0];
        localreport.DataSources.Add(reportDataSource);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM