Blank Tablix

0

I am trying to use the Report Viewer, but the Tablix data is blank

Loadtheform:

reportViewer1.LocalReport.DataSources.Add(newMicrosoft.Reporting.WinForms.ReportDataSource("Tablix1", NCategoria.Mostrar()));

Business Layer

ReportViewer

ColumnName:

DataLayer

 public DataTable Mostrar()
        {
            DataTable DtResultado = new DataTable("categoria");
            SqlConnection SqlCon = new SqlConnection();
            try
            {
                SqlCon.ConnectionString = Conexao.Cn;
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection = SqlCon;
                SqlCmd.CommandText = "spmostrar_categoria";
                SqlCmd.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter sqlDat = new SqlDataAdapter(SqlCmd);
                sqlDat.Fill(DtResultado);
            }
            catch
            {
                DtResultado = null;
            }
            return DtResultado;
        }
    
asked by anonymous 09.10.2017 / 00:17

1 answer

0

Greetings. I'll post as I do and see if it helps. First make sure your DataTable is bringing the bank data. Then change the code and test to see if it will work. The only difference I see is that you use DataTable teste and I use Collection .

private void frmRecategoria_Load(object sender, EventArgs e)
{
   DataTable teste = Ncategoria.Mostrar();

   //carrega a tabela do reportviewer
   reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("NomeDoDataSet_doTablix", teste));

this.ReportViewer1.RefreshReport();
}

Make sure that in your table the columns have the same names as the DataTable , for example: CategoryID , CategoryCategory .

    
09.10.2017 / 02:10