Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# RDLC-本地报表处理过程中发生错误。报告定义无效_C#_Winforms_Rdlc - Fatal编程技术网

C# RDLC-本地报表处理过程中发生错误。报告定义无效

C# RDLC-本地报表处理过程中发生错误。报告定义无效,c#,winforms,rdlc,C#,Winforms,Rdlc,我有一份“Form1ReportSale”报表。在它的加载事件中,我想根据来自另一个表单的ID生成RDLC报告。当我将程序置于调试模式时,DataSet返回预期值,但抛出错误 请查收附件 我的“Form1ReportSale”加载事件代码如下: public partial class Form1ReportSale : Form { string CS; private string id; public string UserID { get

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

请查收附件

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

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;
    }
}

查看您提供的路径:

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";

我必须改变道路。谢谢,但现在我收到一个错误
本地报表处理过程中发生的一个错误
Microsoft.ReportingServices.ReportProcessing.ReportPrcoessingException:
此指定操作无效。请帮我解决这个问题…如果它不起作用,请告诉我..reportViewer1.LocalReport.ReportPath=“Form1ReportSale.rdlc”;我的数据表中有一个问题。当我运行查询
时,选择*
,但我没有在数据表中设置几个字段。无论如何,谢谢你,我正在考虑你的问题