Bonjour
J'ai déjà répondu ici même et donnés quelques fonctions que j'utilise tout le temps pour accéder à mes bases de données, Access 2000 pour moi, pas de différence avec 2003 pour l'accès au mdb.
Pour créer un Recordset et y accéder
Local $oConn = _ADO_Open("c:\xxx.mdb")
Local $_oRS = ObjCreate("ADODB.Recordset")
$_oRS.Open($SQL, $oConn, $adOpenStatic, $adLockOptimistic)
j'imagine que tu connais quand même bien les objets ADO.
► Afficher le texteExemples de fonction
Code : Tout sélectionner
Func _ADO_Open($base, $driver = "", $serveur = "" , $user = "", $pwd = "")
Local $oConn = ObjCreate("ADODB.Connection")
With $oConn
Switch StringLower($driver)
Case "excel"
.ConnectionString = "Driver={Microsoft Excel Driver (*.xls)};Dbq=" & $base
.Open
Case "text"
.ConnectionString = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" & $base & ";Extensions=tab;Extended Properties=TEXT"
.Open
Case "mssql"
.ConnectionString = "driver={SQL Server};server=" & $serveur & ";db=" & $base & ";user id=" & $user & ";pwd=" & $pwd & ";option=16386"
.Open
Case Else
.Provider = $adoProvider
.Open($base)
EndSwitch
EndWith
Return $oConn
EndFunc ;==>_ADO_Open
Func Files_toADORS(ByRef $a)
Local $_oRS = ObjCreate("ADODB.Recordset")
$_oRS.Open("SELECT * FROM FICHIERS", $oConn, $adOpenStatic, $adLockOptimistic)
With $_oRS
For $i = 1 To $a[0]
If $a[$i] = "" Then ContinueLoop
Local $filter = "Full_Path='" & StringReplace($a[$i], "'", "''") & "'"
.Filter = $filter
If .RecordCount = 0 Then
.AddNew
.Fields("Full_Path" ).Value = $a[$i]
EndIf
Local $szDrive, $szDir, $szFName, $szExt
_PathSplit($a[$i], $szDrive, $szDir, $szFName, $szExt)
.Fields("File" ).Value = $szFName
.Fields("Taille" ).Value = FileGetSize($a[$i])
Next
.Update
.Close
EndWith
EndFunc ;==>Files_toADORS
► Afficher le texteConstantes ADO
Code : Tout sélectionner
#Region Constantes
Global Const $adoProvider = 'Microsoft.Jet.OLEDB.4.0'
Global Const $adPersistXML = 1
Global Const $adUseClient = 3
Global Const $adSchemaTables = 20
Global Const $adVarChar = 200
Global Const $adClipString = 2
Global Const $MaxCharacters = 255
;CursorTypeEnum Constants
Global Const $adOpenUnspecified = -1
Global Const $adOpenForwardOnly = 0
Global Const $adOpenKeyset = 1
Global Const $adOpenDynamic = 2
Global Const $adOpenStatic = 3
;LockTypeEnum Constants
Global Const $adLockUnspecified = -1
Global Const $adLockReadOnly = 1
Global Const $adLockPessimistic = 2
Global Const $adLockOptimistic = 3
Global Const $adLockBatchOptimistic = 4
;CommandTypeEnum Constants
Global Const $adCmdFile = 256
Global Const $adCmdStoredProc = 4
Global Const $adCmdTable = 2
Global Const $adCmdTableDirect = 512
Global Const $adCmdText = 1
Global Const $adCmdUnknown = 8
Global Const $adCmdUnspecified = -1
;EditModeEnum
Global Const $adEditNone = 0
Global Const $adEditInProgress = 1
Global Const $adEditAdd = 2
Global Const $adEditDelete = 4
;ExecuteOptionEnum Constants
Global Const $adAsyncFetch = 32
Global Const $adAsyncFetchNonBlocking = 64
;BookmarkEnum
Global Const $adBookmarkCurrent = 0
Global Const $adBookmarkFirst = 1
Global Const $adBookmarkLast = 2
;GetRowsOptionEnum
Global Const $adGetRowsRest = -1
;ObjectStateEnum
Global Const $adStateClosed = 0
Global Const $adStateOpen = 1
Global Const $adStateConnecting = 2
Global Const $adStateExecuting = 4
Global Const $adStateFetching = 8
#EndRegion Constantes