IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Développement Windows Discussion :

Boucle For each


Sujet :

Développement Windows

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Inscrit en
    Avril 2010
    Messages
    47
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2010
    Messages : 47
    Points : 38
    Points
    38
    Par défaut Boucle For each
    Bonjour à tous !
    J'ai une petite question, est-ce que l'on peux avoir deux boucle FRO EACH inclue l'une dans l'autre genre

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    for each a in b
         for each c in d
     
         next
    next
    car j'ai un problème dans l'un de mes codes,

    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
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
     
                    ''Valeur du tableau 
     
                    Dim ValPreparateur As String
                    Dim B, C, D As Integer
                    Dim dr, dr2 As DataRow
     
                    X = 100
                    Y = 300
                    Z = 1
                    C = 0
                    D = 0
     
                    TextSql = "select distinct datepvt from " & Choix & " where datepvt between " & IntDateStart & " and " & IntDateEnd & " group by datepvt order by datepvt asc"
                    Dim CmdImpression = New OleDbCommand(TextSql, DBAccess)
                    DRImpressionsDate = CmdImpression.ExecuteReader
     
                    TextSql = "select nomuser, datepvt, format(avg(productivite),'##.##') as moyenne from " & Choix & " where datepvt between " & IntDateStart & " and " & IntDateEnd & " group by nomuser, datepvt order by nomuser asc, datepvt asc "
                    Dim CmdImpression2 = New OleDbCommand(TextSql, DBAccess)
                    DRImpressionsInfos = CmdImpression2.ExecuteReader
     
                    TextSql = "select distinct nomuser from " & Choix & " where datepvt between " & IntDateStart & " and " & IntDateEnd & " group by nomuser order by nomuser asc"
                    Dim CmdImpression3 = New OleDbCommand(TextSql, DBAccess)
                    DRImpressionsPreparateur = CmdImpression3.ExecuteReader
     
                    If DRImpressionsPreparateur.HasRows = True Then
                        For Each datarow In DRImpressionsPreparateur
                            ValPreparateur = DRImpressionsPreparateur.GetString(0).ToString
     
                            TextSql = "select nomuser, datepvt, format(avg(productivite),'##.##') as moyenne from " & Choix & " where datepvt between " & IntDateStart & " and " & IntDateEnd & " and nomuser = '" & ValPreparateur & "' group by nomuser, datepvt order by nomuser asc, datepvt asc "
                            Dim DRImpressionsDate2 As OleDbDataReader
                            Dim CmdImpressionDate2 = New OleDbCommand(TextSql, DBAccess)
                            DRImpressionsDate2 = CmdImpressionDate2.ExecuteReader
     
                            text = ValPreparateur
                            e.Graphics.DrawString(text, PrintText, System.Drawing.Brushes.Black, 50, 200)
                            B = 0
                            If DRImpressionsDate2.HasRows = True Then
                                For Each dr2 In DRImpressionsDate2
     
                                    If DRImpressionsDate2.GetInt32(1).ToString = IntDateStart Then
                                        text = DRImpressionsDate2.GetInt32(2).ToString
                                        e.Graphics.DrawString(text, PrintText, System.Drawing.Brushes.Black, 200, 200 + A)
                                    Else
                                        Dim ValEcart As Integer
                                        ValEcart = DRImpressionsDate2.GetInt32(1).ToString - IntDateStart
                                        text = DRImpressionsDate2.GetInt32(2).ToString
                                        e.Graphics.DrawString(text, PrintText, System.Drawing.Brushes.Black, (ValEcart * 100) + 200, 200 + A)
                                    End If
     
                                    If Z = 1 Then
                                        If DRImpressionsDate.HasRows = True Then
                                            Dim DataRowDate As DataRow
                                            X = 0
                                            For Each DataRowDate In DRImpressionsDate
                                                text = Mid(DRImpressionsDate.GetInt32(0).ToString, 6, 2) & "/" & Mid(DRImpressionsDate.GetInt32(0).ToString, 4, 2)
                                                e.Graphics.DrawString(text, PrintText, System.Drawing.Brushes.Black, 200 + X, 180)
                                                X += 50
                                            Next
                                        End If
                                    End If
                                    B += 20
                                Next
                            End If
                            Z += 1
                        Next
                    End If
    La ligne

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    For Each dr2 In DRImpressionsDate2
    plante mais je ne sais pas pourquoi puisque je lui dit que

    il me met comme message : impossible d'effectuer un cast d'un objet de type 'system.data.common.datarecordinternal' en type 'system.data.datarow'

    je cherche sur internet mais je ne trouve rien de ... clair ... pour le moment
    je viens de parcourir la bibliothèque msdn sans résultat ...

  2. #2
    Membre expert
    Avatar de GuruuMeditation
    Homme Profil pro
    .Net Architect
    Inscrit en
    Octobre 2010
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : .Net Architect
    Secteur : Conseil

    Informations forums :
    Inscription : Octobre 2010
    Messages : 1 705
    Points : 3 568
    Points
    3 568
    Par défaut
    Regarde ici, le gars a résolu en faisant un Read : http://forums.asp.net/t/1770575.aspx
    Microsoft MVP : Windows Platform

    MCPD - Windows Phone Developer
    MCPD - Windows Developer 4

    http://www.guruumeditation.net

    “If debugging is the process of removing bugs, then programming must be the process of putting them in.”
    (Edsger W. Dijkstra)

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    Inscrit en
    Avril 2010
    Messages
    47
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2010
    Messages : 47
    Points : 38
    Points
    38
    Par défaut
    Bonjour GuruuMeditation,

    dans des tentatives complètement surperflue (je testais sans vraiment y croire) j'ai réussi à ce que cela fonctionne ...

    plus j'avance dans VB.net en complexité de devellopement plus cela me parait complètement incompréhensible ... je m'explique,

    cette nuit vers 02h00 du matin j'en avais un peux marre, j'avais fait des test et des recherches toutes la journée et j'ai fait une chose auquel j'avais pas pensée jusque là,

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    dim dr, dr2 as data.common.dbdatarecord
    je voulais les declarés comme "system.data.common.datarecordinternal" mais cela n'existe pas et j'ai trouver "data.common.dbdatarecord" à la place, j'ai essayer, tous fonctionne ...

    je n'aie plus de plantage on dirait que sa fonctionne comme un datarow ...

    merci pour ta proposition quand même ;D

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. boucle for each
    Par jadey dans le forum VB 6 et antérieur
    Réponses: 2
    Dernier message: 30/08/2006, 20h50
  2. [VBA-E]PB sur une boucle for each next
    Par rond24 dans le forum Macros et VBA Excel
    Réponses: 9
    Dernier message: 31/07/2006, 15h47
  3. aide vba boucle for each paramétrée en range
    Par gotlieb dans le forum Macros et VBA Excel
    Réponses: 6
    Dernier message: 27/07/2006, 08h55
  4. [VBA-E] erreur boucle for each
    Par Mut dans le forum Macros et VBA Excel
    Réponses: 6
    Dernier message: 15/02/2006, 16h38
  5. Boucle For each
    Par roots_man dans le forum ASP
    Réponses: 10
    Dernier message: 18/02/2005, 09h55

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo