Author: cgr Language: text
Description: Not specified Timestamp: 2017-10-06 22:13:13 +0000
View raw paste Reply
#AutoIt3Wrapper_UseX64=N
Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

Dim $Server, $Database, $UserID, $PWD, $DB_CONNECT_STRING
;==== Server = ====
$Server = "ServerIP,Port#"
$Database = "DBname"
$UserID = "myID"
$PWD = "myPassword"

$DB_CONNECT_STRING = "Provider=ASEOLEDB; Data Source=" & $server & "; Initial Catalog=" & $database & "; User Id = " & $UserID & "; Password=" & $PWD & ";"
$Conn = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$RS.CursorType = 3
$Conn.Open($DB_CONNECT_STRING) ;<= Fails here!
$RS.Open("select Top 10 * from TableName",$Conn)

; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
    MsgBox(0, "ErrFunc", $oError.description)
    Exit
EndFunc   ;==>_ErrFunc
View raw paste Reply