Я создал отчет с помощью построителя отчетов 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);
}
}
}