Jump to content

ObjEvent - ADO SQL Error Collections


 Share

Recommended Posts

Here 

https://msdn.microsoft.com/en-us/library/windows/desktop/ms675299(v=vs.85).aspx

I read about:

Any operation involving ADO objects can generate one or more provider errors. As each error occurs, one or more Error objects can be placed in the Errors collection of the Connection object. When another ADO operation generates an error, the Errors collection is cleared, and the new set of Error objects can be placed in the Errors collection.

As I understand when I use:

#include <MsgBoxConstants.au3>

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")
    
    ; some ADO STUFF
    ; .....
    ; .....
    ; .....
    ; .....
    ; .....

EndFunc

; 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)
EndFunc   ;==>_ErrFunc

 

then I get refrerence to single object not to Collections.

 

 

Question:

How I can get Reference to ErrorCollections ?

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

I think somethink like this:

 

 

#include <array.au3>
#include "_sql.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")
    $oADODB_Connection.Open("PROVIDER=SQLNCLI11;SERVER=localhost\SQLExpress;DATABASE=master;uid=sa;pwd=mypass;")
    $oADODB_Connection.BeginTrans
    $oADODB_Connection.Execute('use baza')
    Local $aResult1, $iRows, $iColumns
    _SQL_GetTable2D($oADODB_Connection, 'Select * from table1', $aResult1, $iRows, $iColumns)
    Local $aResult2, $iRows2, $iColumns2
    _SQL_GetTable2D($oADODB_Connection, 'delete from table2', $aResult2, $iRows2, $iColumns2)
    Local $aResult3, $iRows3, $iColumns3
    _SQL_GetTable2D($oADODB_Connection, 'Select * from table3', $aResult3, $iRows3, $iColumns3)
    $oADODB_Connection.CommitTrans
    _ArrayDisplay($aResult1)
    _ArrayDisplay($aResult2)
    _ArrayDisplay($aResult3)


EndFunc   ;==>_Example


; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
;~  Local
    For $err In $oADODB_Connection.errors
        ConsoleWrite(1 & @CRLF)
        ConsoleWrite( _
                @ScriptName & " (" & $err.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
                @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($err.number) & @CRLF & _
                @TAB & "err.windescription:" & @TAB & $err.windescription & @CRLF & _
                @TAB & "err.description is: " & @TAB & $err.description & @CRLF & _
                @TAB & "err.source is: " & @TAB & @TAB & $err.source & @CRLF & _
                @TAB & "err.helpfile is: " & @TAB & $err.helpfile & @CRLF & _
                @TAB & "err.helpcontext is: " & @TAB & $err.helpcontext & @CRLF & _
                @TAB & "err.lastdllerror is: " & @TAB & $err.lastdllerror & @CRLF & _
                @TAB & "err.scriptline is: " & @TAB & $err.scriptline & @CRLF & _
                @TAB & "err.retcode is: " & @TAB & "0x" & Hex($err.retcode) & @CRLF & @CRLF)
    Next
EndFunc   ;==>_ErrFunc

 

 

So I want to check but actually second question comes to me: How to fires collection of error ?


EDIT:

Finally works:

 

#include <array.au3>
#include "_sql.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")
    $oADODB_Connection.Open("PROVIDER=SQLNCLI11;SERVER=localhost\SQLExpress;DATABASE=master;uid=sa;pwd=mypass;")
    $oADODB_Connection.BeginTrans
    $oADODB_Connection.Execute('use baza')
    Local $aResult1, $iRows, $iColumns
    _SQL_GetTable2D($oADODB_Connection, 'Select * from table1', $aResult1, $iRows, $iColumns)
    Local $aResult2, $iRows2, $iColumns2
    _SQL_GetTable2D($oADODB_Connection, 'delete from table2', $aResult2, $iRows2, $iColumns2)
    Local $aResult3, $iRows3, $iColumns3
    _SQL_GetTable2D($oADODB_Connection, 'Select * from table3', $aResult3, $iRows3, $iColumns3)
    $oADODB_Connection.CommitTrans
    _ArrayDisplay($aResult1)
    _ArrayDisplay($aResult2)
    _ArrayDisplay($aResult3)


EndFunc   ;==>_Example


; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    Local $err
    Local $iErrorCnt = $oADODB_Connection.errors.Count
    For $iError = 0 to $iErrorCnt
        $err = $oADODB_Connection.errors.Item($iError)
        ConsoleWrite( _
                'ADO Error Collection: ' & $iError & '/' & $iErrorCnt & @CRLF & _
                @ScriptName & " (" & $err.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
                @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($err.number) & @CRLF & _
                @TAB & "err.windescription:" & @TAB & $err.windescription & @CRLF & _
                @TAB & "err.description is: " & @TAB & $err.description & @CRLF & _
                @TAB & "err.source is: " & @TAB & @TAB & $err.source & @CRLF & _
                @TAB & "err.helpfile is: " & @TAB & $err.helpfile & @CRLF & _
                @TAB & "err.helpcontext is: " & @TAB & $err.helpcontext & @CRLF & _
                @TAB & "err.lastdllerror is: " & @TAB & $err.lastdllerror & @CRLF & _
                @TAB & "err.scriptline is: " & @TAB & $err.scriptline & @CRLF & _
                @TAB & "err.retcode is: " & @TAB & "0x" & Hex($err.retcode) & @CRLF & @CRLF)
    Next
EndFunc   ;==>_ErrFunc

 

and to console output:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "Z:\TOOLs\Macro\FORUM\obj_ErrColl.au3" /UserParams    
+>01:13:43 Starting AutoIt3Wrapper v.15.729.1555.9 SciTE v.3.6.0.0   Keyboard:00000415  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:0415)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\user\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\user\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.0)  from:C:\Program Files (x86)\AutoIt3  input:Z:\TOOLs\Macro\FORUM\obj_ErrColl.au3
+>01:13:44 AU3Check ended.rc:0
>Running:(3.3.14.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "Z:\TOOLs\Macro\FORUM\obj_ErrColl.au3"    
--> Press Ctrl+F11 to Restart or Ctrl+Break -or- F11 to Stop
ADO Error Collection: 0/1
obj_ErrColl.au3 () : ==> COM Error intercepted !
    err.number is:      0x80040E4D
    err.windescription: 
    err.description is:     Login failed for user 'sa'.
    err.source is:      Microsoft SQL Server Native Client 11.0
    err.helpfile is:    
    err.helpcontext is:     0
    err.lastdllerror is:    
    err.scriptline is:  
    err.retcode is:     0x00000000

ADO Error Collection: 1/1
obj_ErrColl.au3 () : ==> COM Error intercepted !
    err.number is:      0x00000000
    err.windescription: 
    err.description is:     
    err.source is:      
    err.helpfile is:    
    err.helpcontext is:     
    err.lastdllerror is:    
    err.scriptline is:  
    err.retcode is:     0x00000000

ADO Error Collection: 0/0
obj_ErrColl.au3 () : ==> COM Error intercepted !
    err.number is:      0x00000000
    err.windescription: 
    err.description is:     
    err.source is:      
    err.helpfile is:    
    err.helpcontext is:     
    err.lastdllerror is:    
    err.scriptline is:  
    err.retcode is:     0x00000000

ADO Error Collection: 0/0
obj_ErrColl.au3 () : ==> COM Error intercepted !
    err.number is:      0x00000000
    err.windescription: 
    err.description is:     
    err.source is:      
    err.helpfile is:    
    err.helpcontext is:     
    err.lastdllerror is:    
    err.scriptline is:  
    err.retcode is:     0x00000000

ADO Error Collection: 0/0
obj_ErrColl.au3 () : ==> COM Error intercepted !
    err.number is:      0x00000000
    err.windescription: 
    err.description is:     
    err.source is:      
    err.helpfile is:    
    err.helpcontext is:     
    err.lastdllerror is:    
    err.scriptline is:  
    err.retcode is:     0x00000000

ADO Error Collection: 0/0
obj_ErrColl.au3 () : ==> COM Error intercepted !
    err.number is:      0x00000000
    err.windescription: 
    err.description is:     
    err.source is:      
    err.helpfile is:    
    err.helpcontext is:     
    err.lastdllerror is:    
    err.scriptline is:  
    err.retcode is:     0x00000000

ADO Error Collection: 0/0
obj_ErrColl.au3 () : ==> COM Error intercepted !
    err.number is:      0x00000000
    err.windescription: 
    err.description is:     
    err.source is:      
    err.helpfile is:    
    err.helpcontext is:     
    err.lastdllerror is:    
    err.scriptline is:  
    err.retcode is:     0x00000000

ADO Error Collection: 0/0
obj_ErrColl.au3 () : ==> COM Error intercepted !
    err.number is:      0x00000000
    err.windescription: 
    err.description is:     
    err.source is:      
    err.helpfile is:    
    err.helpcontext is:     
    err.lastdllerror is:    
    err.scriptline is:  
    err.retcode is:     0x00000000

+>01:13:44 AutoIt3.exe ended.rc:0
+>01:13:44 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.095

mLipok

 

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Here is some improvements:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "Z:\TOOLs\Macro\FORUM\obj_ErrColl.au3" /UserParams    
+>14:29:45 Starting AutoIt3Wrapper v.15.729.1555.6 SciTE v.3.6.0.0   Keyboard:00000415  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0415)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\Michał\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Michał\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.1)  from:C:\Program Files (x86)\AutoIt3  input:Z:\TOOLs\Macro\FORUM\obj_ErrColl.au3
+>14:29:45 AU3Check ended.rc:0
>Running:(3.3.14.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "Z:\TOOLs\Macro\FORUM\obj_ErrColl.au3"    
--> Press Ctrl+F11 to Restart or Ctrl+Break -or- F11 to Stop

! ==> COM Error intercepted ==> ADO Error Collection: .errors.Count = 1   $oErr = .errors.Item(0) 
>   $oErr.description is:       Invalid object name 'table1'.
>   $oErr.number is:        -2147352567   in HEX is  0x80040E37
>      ErrorValueEnum description:  
>   $oErr.source is:        Microsoft SQL Server Native Client 11.0
>   $oErr.SQLState is:      42S02  Description: Base table or view not found
>   $oErr.NativeError is:       208
-   $oError.windescription:     Wystąpił wyjątek.

-   $oError.scriptline is:      21
-   $oError.helpfile is:        
-   $oError.helpcontext is:     0
-   $oError.lastdllerror is:    0
-   $oError.retcode is:         0x80040E37
-   $oError.number is:      0x80020009
! ==> COM End of Error Collections dump.


! ==> COM Error intercepted ==> NOT ADO related Error 
-   $oError.description is:     
-   $oError.number is:      169   in HEX is  0x000000A9
-   $oError.source is:      
-   $oError.windescription:     Variable must be of type 'Object'.
-   $oError.helpfile is:    
-   $oError.helpcontext is:     
-   $oError.lastdllerror is:    0
-   $oError.scriptline is:      23
-   $oError.retcode is:         0x00000000
! ==> COM End of Error dump.

+>14:29:47 AutoIt3.exe ended.rc:0
+>14:29:47 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 2.15

 

EDIT:
oops here you go:  __SQL_ERROR_COLLECTION_TEST.ZIP

Edited by mLipok
fixed problem with attachment

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

I forget to ask.

In the improved version I use such a function:

Func _ErrFunc($oError)
    ; Do anything here.
    Local $iErrorCol_Max = $oADODB_Connection.errors.Count
    If $iErrorCol_Max = 0 Then
        #cs
            ; QUESTION
            ; Why the following VarGetType() return Keyword ?
            Local $oErrorsCollections = $oError.parent
            MsgBox(0, 'VarGetType($oErrorsCollections)', VarGetType($oErrorsCollections))
            Local $vTest = $oErrorsCollections
            MsgBox(0, '$vTest', $vTest)
        #ce
        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_ERROR_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 & _
                    "! ==> End of Error Collections dump." & @CRLF & _
                    "! ==> continue with not ADO related Error:" & @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 dump." & @CRLF & _
                    @CRLF)
        Next
        $oADODB_Connection.errors.clear
    EndIf

EndFunc   ;==>_ErrFunc

I was put there a question:

#cs
    ; QUESTION
    ; Why the following VarGetType() return Keyword ?
    Local $oErrorsCollections = $oError.parent
    MsgBox(0, 'VarGetType($oErrorsCollections)', VarGetType($oErrorsCollections))
    Local $vTest = $oErrorsCollections
    MsgBox(0, '$vTest', $vTest)
#ce

Maybe somebody know the answer ?

 

 

Edited by mLipok
#cs #ce formating in code tag

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

  • 2 weeks later...

hmm..
Maybe somebody know the answer ?
If so , can you share your knowledge ?

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...