Bonjour je créer un petit programme dans lequel j'attaque une base SQL SERVER 2000. Lors de l'ouverture de la requête aucun problème mais lorsque j'essaye de lire la première donnée il me met l'erreur suivante :

Impossible de trouver l'objet dans la collection correspondant au nom où à la référenceordinale demandée

Voila mon 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
 
Sub GSQL()
Dim i, iMax As Integer
Dim nbenregis As Long
Dim Tinit(200), Corres(200), Ligne, Test, Ligne2, Tligne(200), Source, Cible, Car, tabu, Requete, Ligne3, Requete1 As String
Dim arindissql As Database
Dim rstArt As ADODB.Recordset
Set rstArt = New ADODB.Recordset
 
Close
tabu = Chr(9)
Source = Range("Source").Value
Cible = Range("Cible").Value
Open Source For Input As #1 'Ouverture des fichiers
Open Cible For Output As #2
i = 4: While Not (Cells(i, 2) = "#"): i = i + 1: Wend
iMax = i - 4
For i = 1 To iMax: Tinit(i) = Cells(i + 3, 2).Value: Next i
While Not EOF(1)
    Line Input #1, Ligne
    i = 1
    j = 0
    mot = ""
    While Not (i > Len(Ligne))
        Car = Mid(Ligne, i, 1)
        If Car = tabu Then 'Or i = Len(Ligne)
            j = j + 1
            Tligne(j) = mot
            mot = ""
        ElseIf i = Len(Ligne) Then
            mot = mot + Car
            j = j + 1
            Tligne(j) = mot
            mot = ""
        Else
            mot = mot + Car
        End If
        i = i + 1
    Wend
    For i = 1 To iMax: Corres(i) = Tinit(i): Next
    For i = 1 To iMax
        If Left(Corres(i), 1) = "#" Then
            Corres(i) = Tligne(CInt(Right(Corres(i), 2)))
        End If
    Next i
    Ligne2 = ""
    For i = 1 To iMax: Ligne2 = Ligne2 & Corres(i): Next i
    MsgBox Ligne2
    Print #2, Ligne2
Wend
Close
 
 
Open Cible For Input As #3
 
Dim cnx As ADODB.Connection
Set cnx = New ADODB.Connection
'Définition de la chaîne de connexion
cnx.ConnectionString = "UID=" & Administrateur & ";" & "DRIVER={SQL Server};Server=" & "SQL" & ";Database=" & "arindissql" & ";"
'PWD=" & MotDePasse & ";
'Ouverture de la base de données
cnx.Open
cnx.Execute ("exec sp_dboption 'arindissql', 'arithabort', 'TRUE'")
 
While Not EOF(3)
    Ligne3 = ""
    Line Input #3, Ligne3
    Requete = Ligne3
    Ligne3 = ""
    cnx.Execute (Requete)
Wend
'cnx.Execute ("INSERT INTO  F_DOCENTETE (DO_Piece,DO_Type,DO_Domaine,DO_Statut,DO_Tiers) VALUES ('BLA01672', 3, 1, 0, 'COMPIN')")
Close
 
'Pour les ligne de documents
Worksheets("Corps").Activate
Source = Range("SourceLigne").Value
Cible = Range("DestLigne").Value
Open Source For Input As #1 'Ouverture des fichiers
Open Cible For Output As #2
i = 4: While Not (Cells(i, 2) = "#"): i = i + 1: Wend
iMax = i - 4
For i = 1 To iMax: Tinit(i) = Cells(i + 3, 2).Value: Next i
 
While Not EOF(1)
    Line Input #1, Ligne
    i = 1
    j = 0
    mot = ""
    While Not (i > Len(Ligne))
        Car = Mid(Ligne, i, 1)
        If Car = tabu Then 'Or i = Len(Ligne)
            j = j + 1
            Tligne(j) = mot
            mot = ""
        ElseIf i = Len(Ligne) Then
            mot = mot + Car
            j = j + 1
            Tligne(j) = mot
            mot = ""
        Else
            mot = mot + Car
        End If
        i = i + 1
    Wend
    For i = 1 To iMax: Corres(i) = Tinit(i): Next
    For i = 1 To iMax
        If Left(Corres(i), 1) = "#" Then
            Corres(i) = Tligne(CInt(Right(Corres(i), 2)))
        End If
    Next i
    Ligne2 = ""
    For i = 1 To iMax: Ligne2 = Ligne2 & Corres(i): Next i
    MsgBox Ligne2
    Print #2, Ligne2
Wend
Close
 
Open Range("DestLigne").Value For Input As #3
 
'Dim cnx As ADODB.Connection
Set cnx = New ADODB.Connection
 
 
'Définition de la chaîne de connexion
cnx.ConnectionString = "UID=" & Administrateur & ";" & "DRIVER={SQL Server};Server=" & "SQL" & ";Database=" & "arindissql" & ";"
'PWD=" & MotDePasse & ";
'Ouverture de la base de données
cnx.Open
cnx.Execute ("exec sp_dboption 'arindissql', 'arithabort', 'TRUE'")
 
While Not EOF(3)
    Ligne3 = ""
    Line Input #3, Ligne3
    Requete = Ligne3
    Ligne3 = ""
    Requete1 = "SELECT AR_Ref FROM F_ARTICLE WHERE AR_Ref='" & Corres(42) & "'"
    rstArt.Open Requete1, cnx
    Test = rstArt.Fields(1).Value
    'cnx.Execute (Requete)
Wend
Close
Worksheets("Entête").Activate
End Sub
 
L'erreur se situe sur rstArtFields(1).value
Merci