Bonjour,
Dans mon DataViewGrid, j'ai placé un bouton qui, lorsque je clique dessus supprime la ligne concernée du curseur.
Je le fais avec ce code:
Comment dois je faire pour supprimer dans la table l'enregistrement en question ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 private void button3_Click(object sender, EventArgs e) { dataGridView1.Rows.Remove(dataGridView1.CurrentRow); }
Pour afficher les infos de ma table dans le DWG, j'avais fait un truc du genre :
Merci à vous pour votre aide
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 private void Form1_Load(object sender, EventArgs e) { SqlConnection oSQLConn = new SqlConnection(); oSQLConn.ConnectionString = "Server=XXXXXXX-PC\\SQLEXPRESS;Initial Catalog=FILM;Integrated Security = True;"; SqlCommand cmd = new SqlCommand(); string req = "Select * from film"; cmd.CommandText = req; cmd.Connection = oSQLConn; oSQLConn.Open(); DataTable dt = new DataTable(); SqlDataReader dr = cmd.ExecuteReader(); dt.Load(dr); oSQLConn.Close(); dataGridView1.DataSource = dt; oSQLConn.Close(); }
Partager