I have a C # application that performs a search. For this is used a field called 'status' that nothing else a list in a combobox. I need it to appear in addition to the statuses that come from the bank, a status called 'ALL' that does not exist in the bank, and if possible that it comes first in the combobox at the time of listing. Follow my code to list the fields.
String string_conn = ConfigurationManager.ConnectionStrings["conexao"].ConnectionString;
NpgsqlConnection conn = new NpgsqlConnection(string_conn);
try
{
conn.Open();
}
catch (NpgsqlException sqle)
{
MessageBox.Show("Falha ao efetuar a conexão. Erro: " + sqle);
}
String sql = "SELECT * FROM usuario";
NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, conn);
DataTable dtResultado = new DataTable();
dtResultado.Clear();
da.Fill(dtResultado);
Invoke((MethodInvoker)delegate
{
CbUsuario.DataSource = null;
CbUsuario.DataSource = dtResultado;
CbUsuario.ValueMember = "cod";
CbUsuario.DisplayMember = "nome";
CbUsuario.SelectedItem = "";
CbUsuario.Refresh();
});
conn.Close();