0
Is there a better way to search for the content of a specific column? I have information that repeats in a "template" column I want to retrieves this content only 1 time. I’m doing it like this, but maybe there’s 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 "";
}
@Rovannlinhalis, I made the adjustment of the question
– Harry
@Rovannlinhalis, this is an example for study, I’m using . mdb
– Harry
@Rovannlinhalis, this current code, brings me the name of the column, wanted to get the contents of a specific column
– Harry