1
I’m making a report and it’s giving an error message that I’m not finding a solution.
Error:
Code Generate button
private void btnGerarRelatorio_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataSet dsum = new DataSet();
DataTable oTable = new DataTable();
String strReportPath = "";
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);
}
}
Thank you very much helped me, let me ask you to get 2 tables tbEntradaPeca and tbSaidaPeca how would I do that in the report ? I would choose a piece Cod 1 starting date and end date and show me all the entries and exit in the report of this piece, if you can help me I appreciate I need to deliver this day 12 in college.
– Denilson Carlos