and i use mvc4 with vs2012 ,try to crete printable document such as : pdf,word,....
this is class to get customers from northwind database :
namespace MvcApplicationRpt2.Models
{
public class CustomerRpt
{
static public IEnumerable<Customer> GetAllCustomers()
{
var db = new NorthwindEntities();
return db.Customers.AsEnumerable().ToList();
}
}
}
the rdlc i use wizad mode, choose the DataSource: NorthWindDataSet and DataSet: DataSetCustomer
Please can you elaborate on the solution? I am having the same problem, but I'm not sure what you mean. I have tried varying the first parameter passed in to match or differ to the dataset defined in the report, but to no avail. What did you do to get
it working?
ReportDataSource reportDataSource = new ReportDataSource("datasetname", dataset);
namhaivolam
Member
6 Points
19 Posts
error with rdlc and mvc4
Nov 11, 2012 06:16 PM|LINK
i have tried to code follow the post :
http://weblogs.asp.net/rajbk/archive/2009/11/25/rendering-an-rdlc-directly-to-the-response-stream-in-asp-net-mvc.aspx
and i use mvc4 with vs2012 ,try to crete printable document such as : pdf,word,....
this is class to get customers from northwind database :
namespace MvcApplicationRpt2.Models { public class CustomerRpt { static public IEnumerable<Customer> GetAllCustomers() { var db = new NorthwindEntities(); return db.Customers.AsEnumerable().ToList(); } } }the rdlc i use wizad mode, choose the DataSource: NorthWindDataSet and DataSet: DataSetCustomer
http://s756.beta.photobucket.com/user/namhaivolam/media/Untitled.png.html?sort=3&o=0
and the controller :
public ActionResult Index() { var localReport = new LocalReport { ReportPath = Server.MapPath("~/Reports/Report1.rdlc") }; var reportDataSource = new ReportDataSource("Customers", CustomerRpt.GetAllCustomers()); localReport.DataSources.Add(reportDataSource); const string reportType = "PDF"; string mimeType; string encoding; string fileNameExtension; const 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; //Render the report byte[] renderedBytes = localReport.Render( reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); return File(renderedBytes, mimeType); }and when i try to use link
it throw exception:
How can you help me to solve this problem
namhaivolam
Member
6 Points
19 Posts
Re: error with rdlc and mvc4
Nov 12, 2012 02:13 AM|LINK
i ve found the answer the name of ReportDataSource(x,...) x same name of dataset in datasets refrence in data tool opreation !
Stuartq
Member
2 Points
2 Posts
Re: error with rdlc and mvc4
Dec 21, 2012 12:06 AM|LINK
Please can you elaborate on the solution? I am having the same problem, but I'm not sure what you mean. I have tried varying the first parameter passed in to match or differ to the dataset defined in the report, but to no avail. What did you do to get it working?
ReportDataSource reportDataSource = new ReportDataSource("datasetname", dataset);