Bonjour,
j'ai un problème pour l'affichage des données de ma table "fichier " dans dataGridView1,en fait ce que j'ai est un affichage de l'autre côté pas à partir de la première ligne de la dataGridView (1.png(avant déplacement du curseur) et 2.png(après dépalcement du curseur)).
voici mon code:
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 using System; using System.Data; using System.Windows.Forms; using System.Data.SqlClient; namespace WindowsFormsApplication1 { public partial class Form1 : Form { SqlConnection con; SqlDataAdapter dr; DataSet ds = new DataSet(); string pat, req; public Form2() { try{ pat = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Documents and Settings\\Administrateur\\Bureau\\Copie de WindowsFormsApplication1\\WindowsFormsApplication1\\AppData\\Main.mdf;Integrated Security=True;User Instance=True"; req = "SELECT * FROM fichier"; con = new SqlConnection(pat); con.Open(); dr = new SqlDataAdapter(req, con); dr.Fill(ds, "fichier"); } catch (Exception e) { MessageBox.Show("database not find", e.Message); } InitializeComponent(); panel2.Hide(); affich(); } private void affich() { // MessageBox.Show(""+sTable.Rows.Count); //the result is 5 // MessageBox.Show(""+sTable.Rows[0][0].ToString()); //the result is 11 dataGridView1.DataSource = ds.Tables["fichier"]; }
merci pour l'aide
Partager