Public bd As New ADODB.Connection
Public enr As New ADODB.Recordset
Sub chargement()
chaine = "DRIVER={MySQL ODBC 5.1 Driver};SERVER=localhost;DATABASE=connexion_excel;USER='root';PASSWORD='';OPTION=3;"
bd.Open chaine
enr.activeConnection = bd
li = 16
col = 5
For x = 1 To 5
With enr
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open "SELECT * FROM table_test;"
End With
Cells(li + x, 5) = enr("id")
Cells(li + x, 6) = enr("nom")
Cells(li + x, 7) = enr("prenom")
Cells(li + x, 8) = enr("DN")
Cells(li + x, 9) = enr("commentaire")
enr.MoveNext
enr.Close
Next
End Sub