0
I wonder 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. I am doing 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();
}
}
Hi @Felipe. What’s the matter? A
ComboBox
doesn’t get filled in? You have to go into more detail about your problem.– João Martins