Is there a better way to fetch the contents of a specific column? I have information that is repeated in a "template" column I want to retrieve this content only once. I'm doing this, but maybe it has a better way to do it.
public DataSet get()
{
OleDbConnection conn = new OleDbConnection(Conexao.getConexao());
conn.Open();
OleDbDataAdapter da = new OleDbDataAdapter("Select Codigo as Codigo, Nome as Nome,modelo, Cargo as Cargo, Empresa as Empresa From funcionarios", conn);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
private void exibirDados()
{
try
{
funcionarios funci = new funcionarios();
DataSet ds = funci.get();
dgvDados.DataSource = ds.Tables[0];
string retorno = ConteudoColuna("modelo",ds);
}
catch
{
throw;
}
}
private string ConteudoColuna(string nomeColuna, DataSet table)
{
DataTable recebeTable = table.Tables[0];
foreach (DataColumn column in recebeTable.Columns)
{
if (column.ToString() == nomeColuna)
{
string teste2 = column.ToString();
return column.ToString();
}
}
return "";
}