【问题标题】:RDLC- An Error occurred during local report processing. The report definition is not validRDLC - 本地报告处理期间发生错误。报告定义无效
【发布时间】:2017-04-26 06:38:25
【问题描述】:

我有一个报告表格“Form1ReportSale”。在它的加载事件上,我想根据来自另一个表单的 ID 生成 RDLC 报告。当我将程序置于调试模式时,DataSet 返回预期值但抛出错误。

请找附件

我的“Form1ReortSale”加载事件代码如下:

public partial class Form1ReportSale : Form
{
    string CS;
    private string id;
    public string UserID
    {
        get { return id; }
        set { id = value; }
    }
    public Form1ReportSale()
    {
        InitializeComponent();
        CS = ConfigurationManager.ConnectionStrings["BikeDB"].ConnectionString;
    }

    private void Form1ReportSale_Load(object sender, EventArgs e)
    {
        this.WindowState = FormWindowState.Maximized;
        //DataSet1NewCustomerBike dsCustomers = GetData(id);
        reportViewer1.ProcessingMode = ProcessingMode.Local;
        reportViewer1.LocalReport.ReportPath = @"E:\Working Area\Directorate Of IT Project\Own Practices\BikeShowRoom\BikeShowRoom\Reports\Form1ReportSale.cs";
        DataSet ds = new DataSet();
        ds = getDataByID(Convert.ToInt32(id));
        ReportDataSource datasource = new ReportDataSource("DataSet1Customer",ds.Tables[0]);
        this.reportViewer1.LocalReport.DataSources.Clear();
        reportViewer1.LocalReport.DataSources.Add(datasource);
        reportViewer1.LocalReport.Refresh();
        reportViewer1.RefreshReport();
    }

    private DataSet getDataByID(int ID)
    {
        DataSet ds = new DataSet();
        using (SqlConnection con = new SqlConnection(CS))
        {
            SqlCommand cmd = new SqlCommand("SELECT * FROM AddNewBike WHERE ID = '"+ID+"'", con);
            SqlDataAdapter ad = new SqlDataAdapter(cmd);
            con.Open();
            ad.Fill(ds);
        }
        return ds;
    }
}

【问题讨论】:

    标签: c# winforms rdlc


    【解决方案1】:

    查看您提供的路径:

    reportViewer1.LocalReport.ReportPath = @"E:\Working Area\Directorate Of IT Project\Own Practices\BikeShowRoom\BikeShowRoom\Reports\Form1ReportSale.cs";
    

    Form1ReportSale 报告扩展名应该是 .rdlc 而不是 .cs ...复制您为报告提供的正确名称...或试试这个

    reportViewer1.LocalReport.ReportPath = "~/Reports/Form1ReportSale.rdlc";
    

    【讨论】:

    • 我已经改变了路径。谢谢,但现在我得到一个错误An error occured during local report processing,Microsoft.ReportingServices.ReportProcessing.ReportPrcoessingException: 这个指定的操作无效。请帮帮我
    • 试试这个...如果它不起作用然后告诉我..reportViewer1.LocalReport.ReportPath = "Form1ReportSale.rdlc";
    • 我的数据表有问题。当我运行查询select * 但我没有在数据表中设置几个字段。无论如何,谢谢,我正在标记你的问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多