gpt4 book ai didi

asp.net - Report Builder 3.0 出现 VS2010 错误

转载 作者:行者123 更新时间:2023-12-04 18:26:14 25 4
gpt4 key购买 nike

我使用 Report Builder 3.0 构建了一个报表,并尝试在 VS 2010 中使用报表查看器显示它。我不断收到此错误消息。

The report definition is not valid. Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition' which cannot be upgraded.

这是我正在使用的代码。

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问我要不要转换。我说是,然后我收到了这条错误消息。

The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition' which cannot be upgraded.

因此,我将命名空间更改为用于 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”是一个无效的子元素。我删除它然后一切正常!希望这会帮助其他人解决这个问题。

关于asp.net - Report Builder 3.0 出现 VS2010 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5655307/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com