Blank tablix

Asked

Viewed 213 times

0

I tried using Report Viewer, but the data from Tablix is blank

inserir a descrição da imagem aqui Load from the form:

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

Business Layer

inserir a descrição da imagem aqui

Report Viewer

inserir a descrição da imagem aqui

Column name:

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

Data Layer

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

1 answer

0


Greetings. I’ll post it like I do it and see if it helps. First make sure your DataTable He’s bringing the database. Then change the tapeworm and test to see if it’ll work. The only difference I see is that you use the DataTable teste and I use a 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 are with the same names as the DataTable, example: Idcategoria, Category.

  • Dude didn’t work out, until that line I get the information http://prntscr.com/gvevtp

  • In their Tablix put the same column name is in the database. Category = Id_categoria, Description = Desc_categoria. Try to post the code instead of the screen print, it is easier to identify the error. The print hid an important part of the code

  • Dude, I’ve tried it many ways and I still can’t, I updated the topic

  • In the Load code you entered in parentheses**("Tablix1", Ncategoria.Show()**, where the table is(Here it is worth noting that I use a Collection and not a Datatable). Another very important thing is that you debug with breakpoint to check if Datatable is coming).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.