bonjour a tous,
soit le code suivant :
en executant le bout de code pas à pas, j'ai le message d'erreur suivant :
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 for (int i = 1; i <=nbLigne; i++) { int numEnga = 0; decimal sold = 0; decimal montant_Designation = 0; int CodeN = 0; int NumF = 0; req = "select sold,montant_tot_design,CodeN,NumF,Num_Enga from tab_engagement where Exercice=@ExerciceCurrent and Code_SC=@CodeSCCurrent and Code_A = @CodeACurrent and NumF=@NumFCurrent"; connexion.AddParametre("@ExerciceCurrent", SqlDbType.Int, Engagement.Exercice); connexion.AddParametre("@CodeSCCurrent", SqlDbType.Int, Engagement.CodeSC); connexion.AddParametre("@CodeACurrent", SqlDbType.Int, Engagement.CodeA); connexion.AddParametre("@NumFCurrent", SqlDbType.Int, Engagement.NFiche + 1); // Engagement.NFiche+1 connexion.ExecuteReader(); if (connexion.rdr.HasRows) { while (connexion.rdr.Read()) { sold = Convert.ToDecimal(connexion.rdr.GetValue(0)); montant_Designation = Convert.ToDecimal(connexion.rdr.GetValue(1)); // ici j'ai le message d'erreur. CodeN = Convert.ToInt32(connexion.rdr.GetValue(2)); NumF = Convert.ToInt32(connexion.rdr.GetValue(3)); numEnga = Convert.ToInt32(connexion.rdr.GetValue(4)); } } }
l'exception est générée au niveau de la ligne :Index was outside the bounds of the array.
Code : Sélectionner tout - Visualiser dans une fenêtre à part montant_Designation = Convert.ToDecimal(connexion.rdr.GetValue(1));
il est a noté que lorsque je teste directement la requête sur sqlServer elle me retourne le résultat correcte.
quelqu'un pourrait il me dire ou se situe le problème.
Merci.
Partager