我对RDLC报告有问题。我的报告可以转换为PDF。我的控制器中有以下代码:
private DataSet GetDataSet()
{
MySqlConnection connection = null;
string connstring = string.Format("Server=myWebsite.com;user id=myUsername;password=myPassword;persist security info=True;database=myDatabase");
connection = new MySqlConnection(connstring);
connection.Open();
string sql = string.Format("Select * FROM Reservaties");
MySqlDataAdapter ad = new MySqlDataAdapter(sql, connstring);
DataSet ds = new DataSet();
ad.Fill(ds);
return ds;
}
public ActionResult Reports(string ReportType)
{
LocalReport localreport = new LocalReport();
localreport.ReportPath = Server.MapPath("~/Reports/Report_Reservatie.rdlc");
DataSet ds = GetDataSet();
ReportDataSource rds = new ReportDataSource("Reservaties", ds.Tables[0]);
localreport.DataSources.Add(rds);
string reportType = ReportType;
string mimeType;
string encoding;
string fileNameExtension;
if (reportType == "PDF")
{
fileNameExtension = "pdf";
}
else
{
fileNameExtension = "jpg";
}
string[] streams;
Warning[] warnings;
byte[] renderedByte;
renderedByte = localreport.Render(reportType, "", out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
Response.AddHeader("content-disposition", "attachment:filename + reservaties_report." + fileNameExtension);
return File(renderedByte, fileNameExtension);
}
这是我的观点:
@model int
@{
ViewBag.Title = "Checkout Complete";
}
<h2>@HojapaApplication.Resources.ResourceNL.CheckoutComplete</h2>
<p>@HojapaApplication.Resources.ResourceNL.ThankForTheOrder: @Model</p>
@Html.ActionLink("Export to PDF", "Reports", new { ReportType = "PDF"}, null)
<p>
@HojapaApplication.Resources.ResourceNL.MoreShoppingOrNot
@Html.ActionLink("store","Index", "Home")
</p>
我总是收到此错误:
“本地报告处理期间发生错误。”
有人可以帮我告诉我我做错了吗?
紫衣仙女
相关分类