Salut,
je travaille avec windows form et j'arrive pas a afficher le résultat de la requête sélection dans mon textbox:
Merci a vous
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 public IDataReader selection(SqlConnection con) { IDbCommand cmd=null; IDataReader reader=null; //----- create SQL command try { cmd = con.CreateCommand(); cmd.CommandText = "SELECT * FROM Table4"; reader = cmd.ExecuteReader(); } catch (Exception e) { Console.WriteLine(e.Message); } return reader; } private void ResSelectionForm_Load(object sender, EventArgs e) { object[] dataRow; InterEnseignant enseignant = new DAOEnseignant(); string connStr = "Data Source=Meine-Derham\\SQLEXPRESS;Initial Catalog=insat;Integrated Security=True "; SqlConnection con = null; // declare connection object con = new SqlConnection(connStr); IDataReader reader=enseignant.selection(con); while (reader.Read()) { textBox1.Text += string.Format("{0}\t\t{1}", reader.GetString(0), reader.GetString(1)) + Environment.NewLine; }}![]()
Partager