salam
pour manipuler des table j'ai créer des procédures de ce genre :
le problème c'est qu'a chaque fois que j'ouvre une table tous le autre ce vide a cause de datasetproduction.Clear();
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 private void tableordreproduction(object sender, EventArgs e) { datasetproduction.Clear(); ordre_production.SelectCommand = new OleDbCommand(); ordre_production.SelectCommand.Connection = Connectionproduction; ordre_production.SelectCommand.CommandText = "SELECT ordre_production.nop, ordre_production.achevement_op, ordre_production.preorite, ordre_production.cleproduit FROM ordre_production WHERE (((ordre_production.achevement_op)=No)) ORDER BY ordre_production.preorite;"; ordre_production.SelectCommand.CommandType = CommandType.Text; Connectionproduction.Open(); ordre_production.Fill(datasetproduction, "ordre_production"); Connectionproduction.Close(); gridop.DataSource = datasetproduction; gridop.DataMember = "ordre_production"; } }
que je suis obliger de le mettre pour vider a chaque fois ma table pour ne pas me retrouver avec une table avec mille doublons.
pour remédier a ça j'ai penser a Vérifier l’existence de ma table : si elle existe je vide ma table pour la remplir a nouveau .
mais bon ça n'a pas marcher puisque j'ai eu le droit a une erreur , (problème d'assignation) .
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 private void tableordreproduction(object sender, EventArgs e) { if (datasetproduction.Tables["ordre_production"] == null)//si la table existe { datasetproduction.Tables["ordre_production"].Clear();//vider la table ordre_production.SelectCommand = new OleDbCommand(); ordre_production.SelectCommand.Connection = Connectionproduction; ordre_production.SelectCommand.CommandText = "SELECT ordre_production.nop, ordre_production.achevement_op, ordre_production.preorite, ordre_production.cleproduit FROM ordre_production WHERE (((ordre_production.achevement_op)=No)) ORDER BY ordre_production.preorite;"; ordre_production.SelectCommand.CommandType = CommandType.Text; Connectionproduction.Open(); ordre_production.Fill(datasetproduction, "ordre_production"); Connectionproduction.Close(); gridop.DataSource = datasetproduction; gridop.DataMember = "ordre_production"; } }
merci d'avance.
Partager