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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
public partial class ListeUsers : Form
{
private Connexion AdoCnx;
private MySqlCommand CmdSelect;
private MySqlDataAdapter MonDataAdapter;
private DataSet ds = new DataSet();
private string AfficheSQL;
MySqlConnection conn;
public ListeUsers()
{
InitializeComponent();
}
private void ListeUsers_Load(object sender, EventArgs e)
{
try
{
AdoCnx = new Connexion();
conn = AdoCnx.OpenBase();
}
catch (Exception erreur)
{
MessageBox.Show(erreur.Message,"Erreur",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
try
{
AfficheSQL = "SELECT id_util,login_util,nom_util,prenom_util FROM utilisateurs";
CmdSelect = new MySqlCommand(AfficheSQL,conn);
CmdSelect.CommandType = CommandType.Text;
MonDataAdapter = new MySqlDataAdapter(CmdSelect);
ds.Clear();
MonDataAdapter.Fill(ds);
this.dataGridView1.DataSource = ds.Tables[0];
}
catch (Exception ex)
{ MessageBox.Show(ex.Message,"Erreur",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
conn.Close();
}
} |
Partager