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