繁体   English   中英

带有VS2010错误的Report Builder 3.0

[英]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.CommonMicrosoft.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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM