Bonjour,
Je fais deux requetes pour allimenter un datatable le seul probleme c'est que j'ecrase toujours les données du datatable quand d'autre arrivent et je n'trouve pas la syntaxe...
si quelqu'un peut m'aider, merci d'avance.
Les requetes :
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 private void InitDGV() { try { CnxOracle.ConnectionBdd(); DTInfoClts = CnxOracle.GetClientMails(CnxOracle.almasId); nbreLigne = CnxOracle.ALGetClientMails.Count; CnxOracle.connectionfin(); for (int i = 0; i < nbreLigne; i++) { string var = DTInfoClts.Rows[i][0].ToString(); CnxOracle.ConnectionBdd(); DTInfoCltsBis = CnxOracle.GetInfoClt(var); CnxOracle.connectionfin(); } } catch (Exception msgErreur) { MessageBox.Show(msgErreur.Message); } CnxOracle.connectionfin(); dgvClt.DataSource = DTInfoCltsBis; }
et
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 public static DataTable GetClientMails(string paraIdRub) { try { sql = "Select id_client from ABONNEMENT where ID_RUBRIQUE = '" + paraIdRub + "'"; cmd = new OracleCommand(sql, conn); cmd.CommandType = CommandType.Text; da = new OracleDataAdapter(cmd); OracleDataReader dr = cmd.ExecuteReader(); ALGetClientMails.Clear(); DGVGetClientMails.Items.Clear(); while (dr.Read()) //Tant qu'il lit le fichier { DGVGetClientMails.Items.Add(dr.GetValue(0).ToString()); } ALGetClientMails.AddRange(DGVGetClientMails.Items); cb = new OracleCommandBuilder(da); ds = new DataSet(); da.Fill(ds); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("L'erreur suivante c'est produite : " + ex.Message); } return ds.Tables[0]; }
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 public static DataTable GetInfoClt(string paraMail) { sql = "SELECT MAILCLT, NOMCLT, PRENOMCLT from cLIENT where MAILCLT ='" + paraMail + "'"; cmd = new OracleCommand(sql, conn); cmd.CommandType = CommandType.Text; da = new OracleDataAdapter(cmd); OracleDataReader dr = cmd.ExecuteReader(); ALGetInfoClt.Clear(); DGVGetInfoClt.Items.Clear(); while (dr.Read()) //Tant qu'il lit le fichier { DGVGetInfoClt.Items.Add(dr.GetValue(0).ToString()); } ALGetInfoClt.AddRange(DGVGetInfoClt.Items); //strMail = dr.GetValue(0).ToString(); //strNOm= dr.GetValue(1).ToString(); //strPrenom = dr.GetValue(2).ToString(); cb = new OracleCommandBuilder(da); ds = new DataSet(); da.Fill(ds); return ds.Tables[0]; }
Partager