1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| public partial class Form1 : Form
{
NpgsqlConnection cnx;
NpgsqlCommand cmd;
NpgsqlDataAdapter ada;
DataTable dt=new DataTable();
public Form1()
{
InitializeComponent();
}
private void cb1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void Afficher()
{
try
{
dt= new DataTable();
ada.Fill(dt);
cb1.DataSource = dt;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void Form1_Load(object sender, EventArgs e)
{
cnx = new NpgsqlConnection("server=localhost;port=5432;user=postgres;database=gestion_quartier");
InitializeComponent();
cmd= new NpgsqlCommand("select id from quartier", cnx);
cb1.DisplayMember = "id";
Afficher();
} |
Partager