I would like to know if it is possible to pass data from an SQL query to a combobox using C #. I researched the subject and found examples, but when I adapted to my case, I could not use it. I'm doing it this way:
private void carregacombo()
{
Conexao conexão = new Conexao();
try
{
conexão.conectar();
OleDbCommand cmd = new OleDbCommand("select nomeEquipe from Equipe",conexão.cn);
OleDbDataAdapter da = new OleDbDataAdapter();
DataTable dtMensagens = new DataTable();
da.Fill(dtMensagens);
this.cmbEquipe.DataSource = dtMensagens;
this.cmbEquipe.DisplayMember = "nomeEquipe";
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
conexão.desconectar();
}
}