Questions about the datagridview

1
Hello, I have some questions about the datagridview of visual studio, I would like to know how I can change the values of the columns that appear to the foreign key of the sql server by the value of the table that is referenced to the primary key, and also wanted to know how I can add the total of the displayed values

I'mtryingtousethecodebutIcannotfigureoutwhyIcannotputaStringinthecolumnsbecauseI'vebeensettointandIcannotchangethat.

publicstaticDataTablefillDataTable(stringquery){using(OdbcConnectionconexao=Conexao.CreateConnection()){OdbcCommandcomando=newOdbcCommand(query,conexao);conexao.Open();DataTabledt=newDataTable();try{dt.Load(comando.ExecuteReader());for(inti=0;i<dt.Rows.Count;i++){Stringquery2="SELECT * FROM tbTipoConta WHERE idTipoConta = "+dt.Rows[i][1];
                        List<TipoDeConta> t = CRUD_TipoDeConta.consultaTipoConta(query2);
                        dt.Rows[i][1]= t[0].nomeTipoDeConta;
                    }
                }
                catch (Exception e)
                {

                    throw;
                }

                return dt;
            }
        }
    
asked by anonymous 10.07.2015 / 02:56

1 answer

1

From what I understand, you want to list the names of related tables instead of your FK Ids and for that you will have to use the inner join of sql to get the desired result. Check it out: link

    
11.07.2015 / 17:27