Loading a DataGridView only with the Id of the Father's table RRS feed

  • Question

  • Hi folks, good afternoon, I need your help on the following code:

    the line underlined is not compiling. 

    The idea of this code is to fill the dataGridView2 with the data from the table, that contains the same Id's Father table.

     My code:

       void TrySincronizarTituloaPagarXnumeroParcelasaPagar()
                     String StrConn;
                     StrConn = @"Data Source=DESKTOP-3O98051;Initial Catalog=SGFRenaissance;Integrated Security=True";
                     SqlConnection sqlConnection = new SqlConnection(StrConn);
                     string sql = string.Format("select  Cod_Entrada_Titulos_a_Pagar from Numero_Parcelas_a_Pagar where

                     Cod_Entrada_Titulos_a_Pagar ='{0}'", cod_Entr_Tit_a_Pagartextbox.Text); // <== Id of Father's table.
                     SqlCommand sqlComm = new SqlCommand(sql, sqlConnection);
                     SqlDataReader reader = sqlComm.ExecuteReader();
                     while (reader.Read())

                       //  dataGridView2.????? = reader["Cod_Entrada_Titulos_a_Pagar"].ToString(); // not compiling




    * ???? dataGridView2.Cell[0] => or rows that contains the same Id from the cod_Entr_Tit_a_Pagartextbox.Text

    and fill the dataGridView only with that respective Id value.

    Can anyone make a Lambda code for that? It would work fine.

    Obs. the first cell [0] of the  dataGridview2 contains the Id of  the table, where should be the same of the  cod_Entr_Tit_a_Pagartextbox.Text (father's table).

    Thanks for your attention.

    Sunday, March 17, 2019 5:19 PM