I can fill a combobox with DataTable, but in my case I need to fill 2 combobox and 1 checkedboxlist with data from a MySQL bd
//formulário cadastro
private void frmCadastroRecibo_Load(object sender, EventArgs e)
{
Classes.DBconect con = new Classes.DBconect();
string sqlc = "SELECT * FROM cliente";
DataTable dtc = new DataTable();
MySqlDataReader drc = con.returnDataR(sqlc);
dtc.Load(drc);
cmbCliente.DisplayMember = "nome";
cmbCliente.ValueMember = "id";
cmbCliente.DataSource = dtc;
}
//classe de ligação aplicação e bd
public MySqlDataReader returnDataR(string querySql)
{
str_sql = querySql;
MySqlConnection exec = new MySqlConnection();
exec = abrirBanco();
MySqlCommand comando = new MySqlCommand();
comando.CommandText = str_sql.ToString();
comando.Connection = exec;
MySqlDataReader sqlReader = comando.ExecuteReader();
return sqlReader;
}
How can I do this?