Bonjour a tous
voila mon probleme je souhaite donc creer un datagridview pour afficher ma base de donnée mais le message "fill la propriété selectcommand connection n pas été initialisée " s'affiche quand je souhaite l'afficher.
voila mon code :
quelqu'un peut m'aider ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 private void textBox1_TextChanged(object sender, EventArgs e) { string config = "server=127.1.0.1;user id=root;database=cdm;persistsecurityinfo=True"; MySqlConnection con = new MySqlConnection(config); MySqlCommand cmd = new MySqlCommand("Select * Date from match where Equipe2= " + textBox1.Text); try { MySqlDataAdapter ad = new MySqlDataAdapter(); ad.SelectCommand = cmd; DataTable db = new DataTable(); ad.Fill(db); cmd.Connection=con; BindingSource bsource = new BindingSource(); bsource.DataSource = ad; dataGridView1.DataSource = bsource; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
merci d'avance![]()
Partager