#include <_sql.au3> #include Opt ("trayIconDebug",1) Msgbox(0,"","Start the Script and load the error handler") _SQL_RegisterErrorHandler();register the error handler to prevent hard crash on COM error $oADODB = _SQL_Startup() If $oADODB = $SQL_ERROR then Msgbox(0 + 16 +262144,"Error",_SQL_GetErrMsg()) If _sql_Connect(-1,".\SQLEXPRESS","MSSQL_Test","sa","Qwerty12") = $SQL_ERROR then Msgbox(0 + 16 +262144,"Error",_SQL_GetErrMsg()) _SQL_Close() Exit EndIf ; Insert record directly trigger key violation error If _SQL_Execute(-1,"INSERT INTO BBKS (ComputerName,Status,Error) VALUES ('"& @computername & "','On;li''ne','None');") = $SQL_ERROR then Msgbox(0 + 16 +262144,"Error",_SQL_GetErrMsg()) ;Trying to check for duplicate computer record and trigger my custom error but can't generate it despite using _SQL_RegisterErrorHandler() and 16 severity level If _SQL_Execute(-1,"exec sptest '" & @computername & "','Offline', 'None' ;") = $SQL_ERROR then Msgbox(0 + 16 +262144,"Error",_SQL_GetErrMsg())