Bonjour à tous,

Je fais une simple requête select all from une table de ma base de donnée (comportant 45000 lignes).
Le soucis est qu'excel met 8 minutes avant de terminer et d'afficher les résulats sur une feuille.

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
 
Private Sub CommandButton1_Click()
 
    Dim cnn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim rsSQL As String
    Dim Rw, c, Col As Long
    Dim MyField, Location As Range
 
    Application.Calculation = xlCalculationManual    
    Application.ScreenUpdating = False
 
    Set cnn = New ADODB.Connection
    Set rs = New ADODB.Recordset
    Set Location = [A2]
 
    cnn.Open "Driver={SQL Server};Server=pnd-fp01\kluwer2005;Database=Exp_GSI;User Id=****;Password=****;"
    rsSQL = "SELECT * from matable"
    rs.Open rsSQL, cnn, adOpenForwardOnly
 
    Rw = Location.Row
    Col = Location.Column
    c = Col
    With rs
         While Not .EOF
              For Each MyField In rs.Fields
                Cells(Rw, c) = MyField
                c = c + 1
                Next MyField
        rs.MoveNext
        Rw = Rw + 1
        c = Col
        Wend
    End With
 
    rs.Close
    Set rs = Nothing
    Set cnn = Nothing
 
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
 
End Sub