Bonjour,

Je viens de clôturer mon poste sur la connexion entre Excel et HFSQL CS.

Voici un autre problème que je n'avais pas lorsque j'utilisais une base MySQL.

Voici le code :
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
68
69
Private Sub ChercherAPS_Click()
Dim dossier As String
Dim cible As Workbook
Dim val1 As Variant
Dim lg As Integer
Dim Obs1 As String
Dim dercol As Integer
Dim idagent
Dim oConnect As New ADODB.Connection
Dim Pconn As String
Dim nbrec
 
 
    Pconn = "DRIVER={HFSQL32};" & _
            "Data source=HFSQL32" & ";" & _
            "USER ID=admin" & ";" & _
            "PASSWORD=**********" & ";" & _
            "Initial Catalog=proteck" & ";"
 
val1 = LstAPS.Value
chemin = ThisWorkbook.Path
dercol = Cells(1, Cells.Columns.Count).End(xlToLeft).Column
 
Set cible = ThisWorkbook
dossier = val1
    With cible.Worksheets("Salaires")
        lg = .Columns("A").Find(dossier, , xlValues, xlWhole).Row
    End With
 
                Obs1 = Sheets("salaires").Cells(lg, 77).Value
                OBSEnCours = Obs1
 
                'Récupération idagent pour select absence injustifiée MySQL
                idagent = Sheets("salaires").Cells(lg, dercol)
 
                If idagent <> 0 Or idagent <> "" Then
                    'SELECT MySQL
                    Dim rs As ADODB.Recordset
 
                       Set rs = New ADODB.Recordset
 
                       'ConnectDB
                    'Absences injustifiées
                       Strsql = "SELECT absencesagent.IDInformations AS IDInformations,absencesagent.DateDebut AS DateDebut,absencesagentjustificatif.Justificatif AS Justificatif,absencesagentdecision.LibelleDecision AS Decision,decisionDate As DecisionDate FROM absencesagent LEFT JOIN absencesagentjustificatif ON absencesagentjustificatif.IDAbsencesAgentJustificatif = absencesagent.Justificatif LEFT JOIN absencesagentdecision ON absencesagentdecision.IDAbsencesAgentDecision = absencesagent.Decision WHERE absencesagent.IDAgent = " & (idagent) & " AND absencesagent.Type = 4 ORDER BY IDInformations DESC LIMIT 5;"
 
                       oConnect.Open (Pconn)
 
                       If oConnect.State = adStateOpen Then
                              MsgBox "Connecté"
                              rs.Open Strsql, (Pconn)
 
                              'Do Until rs.EOF
                              Do While Not rs.EOF                     ' <------------- ICI
                               'Remplissage de la liste
                                Me.ListBoxAbs.AddItem rs!IDInformations
                                n = Me.ListBoxAbs.ListCount - 1
                                Me.ListBoxAbs.List(n, 1) = rs!DateDebut
                                Me.ListBoxAbs.List(n, 2) = rs!Justificatif
                                Me.ListBoxAbs.List(n, 3) = rs!Decision
                                'Me.ListBoxAbs.List(n, 4) = rs!DecisionDate
 
                              rs.MoveNext
                              Loop
 
                              rs.Close
                          Else
                             MsgBox "ko"
                        End If
End if
J'ai une erreur sur la ligne 53 :
Nom : Erreur loop.PNG
Affichages : 85
Taille : 5,0 Ko

Le driver ODBC HFSQL ne supporte pas la boucle ??

Je ne comprends pas bien, j'ai testé la requête sur mon serveur et elle passe sans problème. Je vais tester en limitant à 1 enregistrement et donc pas de boucle mais...

En attendant vos éclairages.

Cordialement,

Fred