Avant toutes chose je tiens a préciser que j'ai testé pleins de choses trouvé sur ce forum mais aussi sur d'autre en Anglais sans jamais y arriver.
Mes compétences en dev ne sont pas terrible faute de temps...
Je cherche a interroger un base Oracle distante depuis autoit.
J'y arrive bien depuis excel avec le plugin sqlxl qui utilise les sources de données ODBC avec le pilote Oracle in Orant12 "SQORA32.dll".
Je m'était arrêté sur ce script mais le résultat est le même peut importe ce que j'utilise :
#include <GUIConstants.au3>
Dim $oMyError
; Initializes COM handler
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$ado = ObjCreate( "ADODB.Connection" ) ; Create a COM ADODB Object with the Beta version
With $ado
; 'Set data source - for OLEDB this is a tns alias, for ODBC it can be 'either a tns alias or a DSN.
; If "provider" is used this means that the ODBC connections is used via DSN.
; if Driver is used = "Driver={Microsoft ODBC for Oracle};Server=TNSnames_ora;Uid=demo;Pwd=demo;" then this is a DSN Less connector
; More Info for Oracle MS KB Q193332
.ConnectionString =("Provider='OraOLEDB.Oracle';Data Source='BDD_TCP.WORLD';User Id='user';Password='password';")
.Open
EndWith
$adors = ObjCreate( "ADODB.RecordSet" ) ; Create a Record Set to handles SQL Records
With $adors
.ActiveConnection = $ado
;.CursorLocation = "adUseClient"
;.LockType = "adLockReadOnly" ; Set ODBC connection read only
.Source = "select * from lot where ense='2401'"
.Open
EndWith
While not $adors.EOF
For $i = 0 To $adors.Fields.Count - 1
ConsoleWrite( $adors.Fields( $i ).Value & @TAB ) ; Columns in the AutoIt console use Column Name or Index
Next
ConsoleWrite(@CR)
$adors.MoveNext ; Go to the next record
WEnd
; This COM error Handler
Func MyErrFunc()
$HexNumber=hex($oMyError.number,8)
Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _
"err.description is: " & @TAB & $oMyError.description & @CRLF & _
"err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
"err.number is: " & @TAB & $HexNumber & @CRLF & _
"err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
"err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
"err.source is: " & @TAB & $oMyError.source & @CRLF & _
"err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
"err.helpcontext is: " & @TAB & $oMyError.helpcontext _
)
SetError(1) ; to check for after this function returns
Endfunc
Dim $oMyError
; Initializes COM handler
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$ado = ObjCreate( "ADODB.Connection" ) ; Create a COM ADODB Object with the Beta version
With $ado
; 'Set data source - for OLEDB this is a tns alias, for ODBC it can be 'either a tns alias or a DSN.
; If "provider" is used this means that the ODBC connections is used via DSN.
; if Driver is used = "Driver={Microsoft ODBC for Oracle};Server=TNSnames_ora;Uid=demo;Pwd=demo;" then this is a DSN Less connector
; More Info for Oracle MS KB Q193332
.ConnectionString =("Provider='OraOLEDB.Oracle';Data Source='BDD_TCP.WORLD';User Id='user';Password='password';")
.Open
EndWith
$adors = ObjCreate( "ADODB.RecordSet" ) ; Create a Record Set to handles SQL Records
With $adors
.ActiveConnection = $ado
;.CursorLocation = "adUseClient"
;.LockType = "adLockReadOnly" ; Set ODBC connection read only
.Source = "select * from lot where ense='2401'"
.Open
EndWith
While not $adors.EOF
For $i = 0 To $adors.Fields.Count - 1
ConsoleWrite( $adors.Fields( $i ).Value & @TAB ) ; Columns in the AutoIt console use Column Name or Index
Next
ConsoleWrite(@CR)
$adors.MoveNext ; Go to the next record
WEnd
; This COM error Handler
Func MyErrFunc()
$HexNumber=hex($oMyError.number,8)
Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _
"err.description is: " & @TAB & $oMyError.description & @CRLF & _
"err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
"err.number is: " & @TAB & $HexNumber & @CRLF & _
"err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
"err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
"err.source is: " & @TAB & $oMyError.source & @CRLF & _
"err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
"err.helpcontext is: " & @TAB & $oMyError.helpcontext _
)
SetError(1) ; to check for after this function returns
Endfunc
Ma question est comment arriver a communiquer avec ma base oracle via les sources de données ODBC que j'utilise déjà pour excel?
Merci par avance pour l'aide que vous pourriez m'apporter.