[英]Report Builder 3.0 With VS2010 Error
我使用Report Builder 3.0構建了一個報表,並試圖在VS 2010中使用報表查看器顯示該報表。我一直收到此錯誤消息。
報告定義無效。 詳細信息:報表定義具有無效的目標名稱空間'http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition',該名稱空間無法升級。
這是我正在使用的代碼。
public partial class ViewReport : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
PopulateReport(GetDataSet("24"), Server.MapPath("/IncidentReportOld.rdl"));
}
private DataSet GetDataSet(string id)
{
string sql = string.Empty;
SqlDataAdapter ada;
string conString = "Data Source=con-sqlc-02;Initial Catalog=Incident;Integrated Security=True";
DataSet ds = new DataSet();
sql = "select * from Rpt_Incident where incidentID = " + id;
ada = new SqlDataAdapter(sql, conString);
ada.Fill(ds, "Incidents");
return ds;
}
private void PopulateReport(DataSet ds, string reportPath)
{
/* Put the stored procedure result into a dataset */
if (ds.Tables[0].Rows.Count == 0)
{
//lblMessage.Text = "Sorry, no record returned in this report";
}
else
{
// Set ReportViewer1
ReportViewer rv = new ReportViewer();
rv.LocalReport.ReportPath = reportPath;
ReportDataSource datasource;
rv.LocalReport.DataSources.Clear();
for (int i = 0; i < ds.Tables.Count; i++)
{
datasource = new ReportDataSource(ds.Tables[i].TableName, ds.Tables[i]);
rv.LocalReport.DataSources.Add(datasource);
}
RenderPDF(rv);
}
}
private void RenderPDF(ReportViewer rv)
{
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
byte[] bytes = rv.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings);
this.Page.Response.ClearHeaders();
this.Page.Response.AddHeader("content-disposition", "inline; filename=IncidentTest.pdf");
this.Page.Response.ClearContent();
this.Page.Response.ContentEncoding = System.Text.Encoding.UTF8;
this.Page.Response.ContentType = "application/pdf";
BinaryWriter writer = new BinaryWriter(this.Page.Response.OutputStream);
writer.Write(bytes);
writer.Close();
//flush and close the response object
this.Page.Response.Flush();
this.Page.Response.Close();
}
private void PopulateReport1(DataSet ds, string reportPath)
{
/* Put the stored procedure result into a dataset */
if (ds.Tables[0].Rows.Count == 0)
{
//lblMessage.Text = "Sorry, no record returned in this report";
}
else
{
// Set ReportViewer1
//ReportViewer rv = new ReportViewer();
ReportViewer1.LocalReport.ReportPath = reportPath;
ReportDataSource datasource;
ReportViewer1.LocalReport.DataSources.Clear();
for (int i = 0; i < ds.Tables.Count; i++)
{
datasource = new ReportDataSource(ds.Tables[i].TableName, ds.Tables[i]);
ReportViewer1.LocalReport.DataSources.Add(datasource);
}
ReportViewer1.LocalReport.Refresh();
//RenderPDF(rv);
}
}
}
實際上,我本人可以解決此問題。
我只是將擴展名從RDL更改為RDLC。 然后我在VS中打開它,VS問我是否要轉換它。 我說是,然后收到此錯誤消息。
報表定義具有無效的目標命名空間'http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition',該命名空間無法升級。
因此,我將命名空間更改為SQL Reporting Services 2008的命名空間。
<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition">
之后,我收到一條錯誤消息,說“ ReportSections”是無效的子元素。 我將其刪除,然后一切正常! 希望這可以幫助其他人解決此問題。
通過將Microsoft.ReportViewer.Common
和Microsoft.ReportViewer.WinForms
的“特定版本”屬性更改為“引用”中的false
,我在winforms項目中解決了此問題。
我遇到了同樣的問題,但是您的解決方案對我不起作用。 我正在使用VS 2013 Express和USED使用ReportBuilder 3.0。 我在msdn論壇上看到,使用ReportBuilder2.0可以解決該問題,它們是正確的。 因此,請嘗試使用Report Builder 2.0。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.