Thank you so much for your helpful links, mLipok!! I am finally able to display the output now.
Here's my example which I'm finally able to see the output in the console.
#include-once
#include <array.au3>
#include "ADO.au3"
Global $oADODB_Connection = ObjCreate("ADODB.Connection")
_Example()
Func _Example()
; Error monitoring. This will trap all COM errors while alive.
; This particular object is declared as local, meaning after the function returns it will not exist.
Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
Local $sPassword ='MyPassword'
$oADODB_Connection.Open("PROVIDER=SQLOLEDB.1;SERVER=localhost;DATABASE=mydb;uid=sa;pwd="&$sPassword&";")
Local $objquery = $oADODB_Connection.Execute("if 1 = 1 print 'this is a test - hello'")
Local $test = $objquery.Parent
;ConsoleWrite('Before CommitTrans' & @CRLF)
;$oADODB_Connection.CommitTrans
EndFunc ;==>_Example
; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
Local $iErrorCol_Max = $oADODB_Connection.errors.Count
If $iErrorCol_Max = 0 Then
ConsoleWrite( @CRLF & _
"! ==> COM Error intercepted ==> NOT ADO related Error " & @CRLF & _
"-" & @TAB & "$oError.description is: " & @TAB & $oError.description & @CRLF & _
"-" & @TAB & "$oError.number is: " & @TAB & @TAB & $oError.number & " in HEX is 0x" & Hex($oError.number) & @CRLF & _
"-" & @TAB & "$oError.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
"-" & @TAB & "$oError.windescription:" & @TAB & @TAB & $oError.windescription & @CRLF & _
"-" & @TAB & "$oError.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
"-" & @TAB & "$oError.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
"-" & @TAB & "$oError.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
"-" & @TAB & "$oError.scriptline is: " & @TAB & @TAB & $oError.scriptline & @CRLF & _
"-" & @TAB & "$oError.retcode is: " & @TAB & @TAB & "0x" & Hex($oError.retcode) & @CRLF & _
"! ==> COM End of Error dump." & @CRLF & _
@CRLF)
Else
Local $oErr
For $iErrorCol_idx = 0 To $iErrorCol_Max - 1
$oErr = $oADODB_Connection.errors.Item($iErrorCol_idx)
ConsoleWrite( @CRLF & _
"! ==> COM Error intercepted ==> ADO Error Collection: .errors.Count = " & $iErrorCol_Max & " $oErr = .errors.Item(" & $iErrorCol_idx & ") " & @CRLF & _
">" & @TAB & "$oErr.description is: " & @TAB & @TAB & $oErr.description & @CRLF & _
">" & @TAB & "$oErr.number is: " & @TAB & @TAB & $oError.number & " in HEX is 0x" & Hex($oErr.number) & @CRLF & _
">" & @TAB & " ErrorValueEnum description:" & @TAB & _ADO_MSDNErrorValueEnum_Description("0x" & Hex($oErr.number)) & @CRLF & _
">" & @TAB & "$oErr.source is: " & @TAB & @TAB & $oErr.source & @CRLF & _
">" & @TAB & "$oErr.SQLState is: " & @TAB & @TAB & $oErr.SQLState & ' Description: ' &_SQLState_Description($oErr.SQLState) & @CRLF & _
">" & @TAB & "$oErr.NativeError is: " & @TAB & @TAB & $oErr.NativeError & @CRLF & _
"-" & @TAB & "$oError.windescription:" & @TAB & @TAB & $oError.windescription & @CRLF & _
"-" & @TAB & "$oError.scriptline is: " & @TAB & @TAB & $oError.scriptline & @CRLF & _
"-" & @TAB & "$oError.helpfile is: " & @TAB & @TAB & $oError.helpfile & @CRLF & _
"-" & @TAB & "$oError.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
"-" & @TAB & "$oError.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
"-" & @TAB & "$oError.retcode is: " & @TAB & @TAB & "0x" & Hex($oError.retcode) & @CRLF & _
"-" & @TAB & "$oError.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
"! ==> COM End of Error Collections dump." & @CRLF & _
@CRLF)
Next
$oADODB_Connection.errors.clear
EndIf
EndFunc ;==>_ErrFunc