Error message generating report

1

I'm making a report and giving an error message that I can not find a solution.

Error:

Generatebuttoncode

privatevoidbtnGerarRelatorio_Click(objectsender,EventArgse){SqlCommandcmd=newSqlCommand();SqlDataAdapterda=newSqlDataAdapter();DataSetdsum=newDataSet();DataTableoTable=newDataTable();StringstrReportPath="";
        try
        {
            strReportPath = @"Report4.rdlc";
            reportViewer1.LocalReport.ReportPath = strReportPath;
            SqlConnection conn = new SqlConnection(@"Data Source=DENILSON-PC;Initial Catalog=dbSistEstoqueEmp;Integrated Security=True");

            cmd.Connection = conn;
            cmd.CommandText = "SELECT * FROM tbEntradaEstoque WHERE cod_peca = @codPeca AND data_ent BETWEEN @dataEnt AND @dataEnt1";
            cmd.CommandType = CommandType.Text;
            conn.Open();
            cmd.Parameters.Add("codPeca", SqlDbType.Int).Value = Convert.ToInt32(txtCodPeca.Text);
            cmd.Parameters.Add("dataEnt", SqlDbType.DateTime).Value = Convert.ToDateTime(maskDataInicial.Text).Date;
            cmd.Parameters.Add("dataEnt1", SqlDbType.DateTime).Value = Convert.ToDateTime(maskDataFinal.Text).Date;

            SqlDataReader oDataReader = cmd.ExecuteReader();
            oTable.Load(oDataReader);
            ReportDataSource myReportDataSource = new ReportDataSource("dbEntSaidaPeca", oTable);
            reportViewer1.Clear();
            reportViewer1.LocalReport.DataSources[0] = myReportDataSource;
            reportViewer1.RefreshReport();


        }
        catch (Exception ex)
        {

            MessageBox.Show(ex.Message);
        }
    }
    
asked by anonymous 01.06.2015 / 01:59

1 answer

1

The name of Dataset passed as argument of ReportDataSource must be the same as that of the configured RDLC file of the report. So the creation of ReportDataSource should be:

 ReportDataSource myReportDataSource = new ReportDataSource("DataSet1", oTable);
    
01.06.2015 / 03:27