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
| Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
'Connexion à la base
dbPath = serveur
conn.Open "Provider = MSDAORA;" & _
"data source=" & dbPath & ";user ID = id; Password = motDePass"
Set cmd.ActiveConnection = conn
'Creation de la requete : detail de la variable
With cmd
.CommandText = "SELECT * FROM SHS_MAIN ORDER BY NUMQ"
.CommandType = adCmdText
.Execute
End With
'Ouverture du recordset
Set rst.ActiveConnection = conn
rst.Open cmd
Dim compt As Long
compt = 0
nbCol = rst.Fields.Count
ReDim tableauMain(317609, nbCol)
Do While Not rst.EOF
compt = compt + 1
For i = 1 To nbCol
tableauMain(compt, i) = rst.Fields(i - 1)
Next i
rst.MoveNext
Loop
MsgBox compt
Pour Access :
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
'Connexion à la base
Dim dbPath As String
dbPath = "C:\Documents and Settings\CUOR\Mes documents\Etude\Temp\shs.mdb"
conn.Open "Provider = Microsoft.Jet.OLEDB.4.0;" & _
"data source=" & dbPath & ";"
'Creation de la requete : detail de la variable
Set cmd.ActiveConnection = conn
With cmd
.CommandText = "SELECT * FROM SHSMain ORDER BY NUMQ"
.CommandType = adCmdText
.Execute
End With
'Ouverture du recordset
Set rst.ActiveConnection = conn
rst.Open cmd
Dim compt As Long
compt = 0
nbCol = rst.Fields.Count
ReDim tableauMain(317609, nbCol)
Do While Not rst.EOF
compt = compt + 1
For i = 1 To nbCol
tableauMain(compt, i) = rst.Fields(i - 1)
Next i
rst.MoveNext
Loop
MsgBox compt |