rdlc and MVC

Posted on 2014-03-21
Medium Priority
Last Modified: 2014-04-06
Hi again,
I am trying to connect a report to go directly to PDF in MVC2
I found code online
 public ActionResult RemarksReport(int id)       
             LocalReport localReport = new LocalReport();            
             localReport.ReportPath = Server.MapPath("~/Reports/RemarksReport.rdlc");
             ReportDataSource reportDataSource = new ReportDataSource("RemarksData", rr.GetRemarksReport(id)); 
             string reportType = "PDF";            
             string mimeType;            
             string encoding;            
             string fileNameExtension;             
             //The DeviceInfo settings should be changed based on the reportType           
             string deviceInfo =           
                 "<DeviceInfo>" +            
                 "  <OutputFormat>PDF</OutputFormat>" +            
                 "  <PageWidth>8.5in</PageWidth>" +            
                 "  <PageHeight>11in</PageHeight>" +            
                 "  <MarginTop>0.5in</MarginTop>" +            
                 "  <MarginLeft>1in</MarginLeft>" +            
                 "  <MarginRight>1in</MarginRight>" +            
                 "  <MarginBottom>0.5in</MarginBottom>" +            
             Warning[] warnings;            
             string[] streams;            
             byte[] renderedBytes;             
             //Render the report            
             renderedBytes = localReport.Render(                
                 out mimeType,                
                 out encoding,                
                 out fileNameExtension,                
                 out streams,                
                 out warnings);            
             //Response.AddHeader("content-disposition", "attachment; filename=NorthWindCustomers." + fileNameExtension);            
             return File(renderedBytes, mimeType);        

Open in new window

and a datasource
    public IList<RemarksReport> GetRemarksReport(int id)
        var result = db.REPORT_Remarks(id);
        return ( from r in result
            select new RemarksReport
                Date = r.DATE,
                FullName = r.FULLNAME,
                Type = r.TYPE,
                Notes = r.NOTES

Open in new window

I can step through it and watch reportDatasource filling up but when it gets to the report its as if it can't see the data.
I get the error
A data source instance has not been supplied for the data source "RemarksReport"

The website I was using http://weblogs.asp.net/rajbk/archive/2009/11/25/rendering-an-rdlc-directly-to-the-response-stream-in-asp-net-mvc.aspx
showing how to generate a report without a dataset.

If anymore info is needed just let me know.

Thank you in advance
Question by:Niall292
  • 4
  • 2
LVL 96

Accepted Solution

Bob Learned earned 2000 total points
ID: 39947395
The only thing I can think of at this moment is that the data source name in the report is different than the name of ReportDataSource--RemarksData.

Author Comment

ID: 39947971
I have made the changes so the names match but still getting errors, again I can watch the data source filling up but then when it gets to the report it seems there is nothing there

Author Comment

ID: 39948063
Something I did, just in case it makes a difference I am changed the ActionLink in the website used to open the report to a type button calling a jquery function
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 2000 total points
ID: 39948188
Can you attach the .rdlc file?

Assisted Solution

Niall292 earned 0 total points
ID: 39949142
Thanks when you told me to send you the rdlc file I was attaching it and thought I would open it as xml and noticed it was still using the other data source. When I changed it, it now runs to the end but I get a different error. Actually a jQuery error. (.PDF is not a function) which is caused by a completely different problem (I think) so thank you for putting me on the right track

Author Closing Comment

ID: 39981022
The comments made especially when TheLearnedOne was looking to see my .rdlc file made me look at it in xml when I did this I seen the file was pointing to the wrong datasource

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…
Watch the video to know the simple way to remove or recover or reset lost or forgotten passwords of Outlook PST file. With Kernel Outlook Password Recovery tool such operation is very easy to perform. It is a freeware with limitation to use with 500…

587 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question