Solved

rdlc and MVC

Posted on 2014-03-21
6
736 Views
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)); 
             localReport.DataSources.Add(reportDataSource);            
             string reportType = "PDF";            
             string mimeType;            
             string encoding;            
             string fileNameExtension;             
             //The DeviceInfo settings should be changed based on the reportType           
             //http://msdn2.microsoft.com/en-us/library/ms155397.aspx            
             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>" +            
                 "</DeviceInfo>";             
             Warning[] warnings;            
             string[] streams;            
             byte[] renderedBytes;             
             //Render the report            
             renderedBytes = localReport.Render(                
                 reportType,                
                 deviceInfo,                
                 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
            }).ToList();
            }

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
0
Comment
Question by:Niall292
  • 4
  • 2
6 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 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.
0
 

Author Comment

by:Niall292
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
0
 

Author Comment

by:Niall292
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
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 96

Assisted Solution

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

Assisted Solution

by:Niall292
Niall292 earned 0 total points
ID: 39949142
@TheLearnedOne.
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
0
 

Author Closing Comment

by:Niall292
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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
grab and show facebook pages event calendars 6 65
getting id from database 5 37
Replace &lt; with < 14 56
SQL Login 17 40
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now