Jump to content

"Operation not allowed when object is closed" sql update query (no result)


Recommended Posts

I am trying to figure out how to detect if ADO object has no result. For some sql select query I just checked $oRecordSet.EOF value and it works, but when I use sql update query then I receive Com error.

$oMyError = ObjEvent("AutoIt.Error", "_ErrFunc")

$oConnection = ObjCreate("ADODB.Connection")
$oConnection.Open("DRIVER={SQL Server};" & $authData & ";")
$SqlQuery = "UPDATE *** SET *** = '1' WHERE *** = ***"
SqlQueryExecute($oConnection, $SqlQuery)

Func SqlQueryExecute($SQL_Connection, $SQL_Query)
    $oRecordSet = $SQL_Connection.Execute($SQL_Query)

    if not IsObj($oRecordSet) then Exit MsgBox($MB_ICONERROR, @ScriptName, "Error while processing query")

    if not $oRecordSet.EOF then ;error com handler says here that object is not closed
        Return $oRecordSet.GetRows
    Else
        ConsoleWrite("Query has been processed successfully but there was no return data" & @CRLF)
        Return 0
    EndIf
EndFunc
    
Func _ErrFunc($oError)
    MsgBox($MB_ICONERROR, @ScriptName, "COM ERROR" & @CRLF & "Description: " & $oError.description & @CRLF "ScriptLine:" & $oError.scriptline)
EndFunc   ;==>_ErrFunc

How to detect if object is closed to avoid com error handler catch the exception?

Link to comment
Share on other sites

SQL update statements don't return a resultset.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Why you just do not use ADO.au3 UDF ?

Func __ADO_Recordset_IsReady(ByRef $oRecordset)
    __ADO_Recordset_IsValid($oRecordset)
    If @error Then
        Return SetError(@error, @extended, $ADO_RET_FAILURE)
    ElseIf $oRecordset.state = $ADO_adStateClosed Then
        Return SetError($ADO_ERR_ISCLOSEDOBJECT, $ADO_EXT_DEFAULT, $ADO_RET_FAILURE)
    ElseIf $oRecordset.state <> $ADO_adStateOpen Then
        Return SetError($ADO_ERR_ISNOTREADYOBJECT, $ADO_EXT_DEFAULT, $ADO_RET_FAILURE)
;~  ElseIf $oRecordset.status <> $ADO_adRecOK Then
;~      Return SetError($ADO_ERR_ISNOTREADYOBJECT, $oRecordset.status, $ADO_RET_FAILURE)
    EndIf
......

 

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

  • 6 months later...
 
I'm in a similar situation.
I connect to a DB2 database on an AS / 400 machine.
Everything works, but I do not know the result of my UPDATE transactions if it is not interrogating each time for the value of the modified row.

I tried to ask $SQLRS.State or $SQLRS.Status, but it does not work.

Can someone please help?

Thank you very much.

;***************************************************************
; How to read Return Code from AS/400 DB2 SQL   UPDATE transaction?.
;***************************************************************

; ODBC error control
$oErrorHandler = ObjEvent("AutoIt.Error", "objError")

; TABLE CONNECTION
$SQLCON=ObjCreate("ADODB.Connection")
If @error Then $SQLCON.Close
    
$SQLCON.Mode= 16 ;Shared
$SQLCON.CursorLocation=2 ;Client Side cursor
$SQLCON.ConnectionTimeout=10

$SQLCON.Open ("DSN=XXX.XXX.XXX.XXX;UID='User1';PWD='Password1';)
If @error Then
   MsgBox(16,"Test","Fail conexion.")
   $SQLCON.Close
   Exit
EndIf


; UPDATE TEST
$SQLRS = ObjCreate("ADODB.Recordset")
If Not @error Then
   $SQLRS.Open("update MY_TABLE set COLUMN2='modificated' where COLUMN2='initial data",$SQLCON)
EndIf

MsgBox(48,"Return Code","State: "&$SQLRS.State&@CRLF&"Status: "&$SQLRS.Status)

$SQLCON.Close
Exit

 

Func objError($oError)
   $T ="Num.Error   : " & $oError.number & @CRLF
   $T&="Description : " & $oError.windescription & @CRLF & @CRLF
   $T&=$oError.description & @CRLF & @CRLF & @CRLF
   $T&="Helpfile : " & $oError.helpfile & @CRLF
   $T&="helpcontext : " & $oError.helpcontext & @CRLF
   $T&="lastDLLerror: " & $oError.lastdllerror & @CRLF & @CRLF& @CRLF
   $T&="Script Line: " & $oError.scriptline & @CRLF
   $T&="Ret.Code    : " & $oError.retcode
   MsgBox(48,"Error Rutine",$T)
EndFunc

*************************************************************

 

 

Link to comment
Share on other sites

1 hour ago, AMFC said:

$SQLRS.Open("update MY_TABLE set COLUMN2='modificated' where COLUMN2='initial data",$SQLCON)

try to change Open method to Execute

$SQLRS = $SQLCON.Execute("update MY_TABLE set COLUMN2='modificated' where COLUMN2='initial data")

 

Edited by maniootek
Link to comment
Share on other sites

Local $ServerAddress = "192.168.0.199,1455\MYSQL"
Local $DatabaseName = "MyDatabase"
Local $UserName = "admin"
Local $Password = "password123"
Local $SQL_Query = "update MY_TABLE set COLUMN2='modificated' where COLUMN2='initial data'"

Local $oErrorHandler = ObjEvent("AutoIt.Error", "objError")
Local $oSqlConnection = ObjCreate("ADODB.Connection")
$oSqlConnection.Open("DRIVER={SQL Server};SERVER=" & $ServerAddress & ";DATABASE=" & $DatabaseName & ";uid=" & $UserName & ";pwd=" & $Password)

Local $oRecordSet = $oSqlConnection.Execute($SQL_Query)

Switch $oRecordSet.State
    Case 0
        MsgBox(0,0,"state=closed")
    Case 1
        MsgBox(0,0,"state=open")
EndSwitch

Func objError($oError)
   $T ="Num.Error   : " & $oError.number & @CRLF
   $T&="Description : " & $oError.windescription & @CRLF & @CRLF
   $T&=$oError.description & @CRLF & @CRLF & @CRLF
   $T&="Helpfile : " & $oError.helpfile & @CRLF
   $T&="helpcontext : " & $oError.helpcontext & @CRLF
   $T&="lastDLLerror: " & $oError.lastdllerror & @CRLF & @CRLF& @CRLF
   $T&="Script Line: " & $oError.scriptline & @CRLF
   $T&="Ret.Code    : " & $oError.retcode
   MsgBox(48,"Error Rutine",$T)
EndFunc

this code show me state value, please try

Link to comment
Share on other sites

I think he want to get result like in MS SQL managment console.

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...
  • 1 year later...
On 5/8/2017 at 9:55 AM, maniootek said:

How to detect if object is closed to avoid com error handler catch the exception?

See:

On 6/15/2011 at 10:41 PM, jchd said:

Currently, ByRef values on COM object methods don't work out of the box. It's even hard to make them work at all.

The simplest route is to issue another SQL statement.

An example using the RecordCount method:

Opt("MustDeclareVars", 1)
;Opt("TrayIconDebug", 1)
OnAutoItExitRegister("OnAutoItExit")

Global $sFilePath =  @DesktopDir & "\test.mdb"

;Help: COM Error Handling
;_ErrADODB From spudw2k
;https://www.autoitscript.com/forum/topic/105875-adodb-example/
Global $errADODB = ObjEvent("AutoIt.Error","_ErrADODB")

Global $cn, $cmd, $rst, $sSQL
Global $CreateTestDataBase = True

Global Const $iCursorType = 3 ;0 adOpenForwardOnly, 3 adOpenStatic
Global Const $iLockType = 3 ;1 adLockReadOnly, 3 adLockOptimistic
Global Const $iOptions = 1 ; Options, 1 Evaluates as a textual definition of a command or stored procedure call ; 2 adCmdTable
$rst = ObjCreate("ADODB.Recordset") ; Create a recordset object
Global $sADOConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & $sFilePath & ";Jet OLEDB:Database Password=123"
;Global $sADOConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $sFilePath & ";Jet OLEDB:Database Password=123"
;Global $sADOConnectionString = 'Driver={Microsoft Access Driver (*.mdb)};Dbq=' & $sFilePath & ';uid=;pwd=MyPassword;'

If $CreateTestDataBase Then
   ;mLipok, https://www.autoitscript.com/forum/topic/180848-example-xls-mdb-from-scratch-with-adox/
   ;https://forums.autodesk.com/t5/visual-basic-customization/ado-connection-create-file-excel/td-p/1675928
   ;https://msdn.microsoft.com/en-us/library/ms675849(v=vs.85).aspx
   ;https://msdn.microsoft.com/en-us/library/ms680934(v=vs.85).aspx
   Global $oCatalog = ObjCreate('ADOX.Catalog')
   FileDelete(@DesktopDir & "\test.mdb")  ; <<< I'm not using $sFilePath for security: in reusing parts of the code
   $cn = $oCatalog.Create($sADOConnectionString)

   ;https://docs.microsoft.com/es-es/office/client-developer/access/desktop-database-reference/create-table-statement-microsoft-access-sql
   ;https://www.w3schools.com/sql/sql_create_table.asp
   ;http://www.vbforums.com/showthread.php?529221-RESOLVED-create-table-as-select-in-MS-Access
   ;https://docs.microsoft.com/es-es/office/client-developer/access/desktop-database-reference/select-into-statement-microsoft-access-sql
   $sSQL = "CREATE TABLE EMPLOYEES" _
      & " (ID int identity, LastName varchar(40), FirstName varchar(40), Title varchar(40)," _
      & " CONSTRAINT MyTableConstraint_PrimaryKey PRIMARY KEY (ID)," _
      & " CONSTRAINT MyTableConstraint_Unique UNIQUE (LastName, FirstName));"
   $cn.Execute($sSQL, Default, 1 + 0x80)  ;adCmdText = 1 , adExecuteNoRecords = 0x80
      ;Some notes:
      ;Create Table Using Another Table
      ;A copy of an existing table can also be created using CREATE TABLE.
      ;The new table gets the same column definitions. All columns or specific columns can be selected.
      ;CREATE TABLE new_table_name AS
      ;SELECT column1, column2,...
      ;FROM existing_table_name
      ;WHERE ....;
      ;The following SQL creates a new table called "TestTables" (which is a copy of the "Customers" table):
      ;CREATE TABLE TestTable AS
      ;SELECT customername, contactname
      ;FROM customers;

      ;$sSQL = "SELECT *" _
      ; & " INTO NEWTABLE" _
      ; & " FROM [" & $sFilePath2 & ";PWD=123].SOMETABLE"
      ;$cn.Execute($sSQL, Default, 1 + 0x80)

   For $i = 1 To 5
      $sSQL = "INSERT INTO EMPLOYEES (LastName, FirstName, Title)" _
      & " VALUES ('" & "LastName_" & $i & "', '" & "FirstName_" & $i & "', '" & "Title_" & $i & "')"
      $cn.Execute($sSQL, Default, 1 + 0x80)  ;adCmdText = 1 , adExecuteNoRecords = 0x80
   Next

Else
   $cn = ObjCreate("ADODB.Connection") ; Create a connection object
   $cn.Open($sADOConnectionString) ; Open the connection
EndIf
;MsgBox(0, "", $cn.ConnectionString)

$cn.CursorLocation = 2 ;2 adUseServer, 3 adUseClient
$cn.CommandTimeout = 60

;https://support.microsoft.com/en-us/help/194973/prb-ado-recordcount-may-return--1
;When you request the RecordCount for a serverside recordset, a -1 may return. This occurs with ActiveX Data Objects (ADO) version 2.0 or later when the CursorType is adOpenForwardonly or adOpenDynamic. Testing with the OLEDB provider for JET and SQL Server produces varying results, depending on the provider.
;Cause: The number of records in a dynamic cursor may change. Forward only cursors do not return a RecordCount.
;Resolution: Use either adOpenKeyset or adOpenStatic as the CursorType for server side cursors
;or use a client side cursor. Client side cursors use only adOpenStatic for CursorTypes regardless of which CursorType you select.

;https://stackoverflow.com/questions/31941487/open-adodb-connection-to-excel-file-in-read-only-mode
;https://www.w3schools.com/asp/prop_rec_mode.asp
;$cn.Mode = 1 ;Read-only

;Execute Method (ADO Command)
;https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/execute-method-ado-command?view=sql-server-2017
;Executes the query, SQL statement, or stored procedure specified in the CommandText or CommandStream property of the Command object.
;Syntax: Set recordset = command.Execute( RecordsAffected, Parameters, Options )

$sSQL = "UPDATE EMPLOYEES SET LastName = 'Davolio', FirstName = 'Nancy', Title = 'President' WHERE ID = 1"

;jchd, June 2100
;https://www.autoitscript.com/forum/topic/129810-the-number-of-records-affected-is-not-returned-for-sqlserver-compact/?do=findComment&comment=902294
;Currently, ByRef values on COM object methods don't work out of the box. It's even hard to make them work at all.
;The simplest route is to issue another SQL statement.

Global $RecordsAffected_not_working = 0

;https://www.w3schools.com/asp/ado_ref_command.asp
;https://www.autoitscript.com/forum/topic/80351-adodb-command-method/
$cmd = ObjCreate("ADODB.Command")
$cmd.ActiveConnection = $cn
$cmd.CommandType = 1 ;adCmdText
$cmd.CommandText = $sSQL
$cmd.Execute($RecordsAffected_not_working, Default, 1 + 0x80)  ;adCmdText = 1 , adExecuteNoRecords = 0x80

MsgBox(0, "Not Counting", $RecordsAffected_not_working)

;https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2007/bb221186(v=office.12)
;UPDATE does not generate a result set. Also, after you update records using an update query, you cannot undo the operation.
;If you want to know which records were updated, first examine the results of a select query that uses the same criteria, and then run the update query.

$sSQL = "SELECT * FROM EMPLOYEES WHERE ID > 1"
$rst.Open($sSQL, $cn, $iCursorType, $iLockType, $iOptions)
If Not $rst.EOF = True Then
   $sSQL = "UPDATE EMPLOYEES SET Title = 'Sales Representative' WHERE ID > 1"
   $cn.Execute($sSQL, Default, 1 + 0x80)  ;adCmdText = 1 , adExecuteNoRecords = 0x80

   MsgBox(0, "UPDATED RECORDS", $rst.RecordCount)
EndIf
$rst.Close

;ADO CommandType Property
;https://www.w3schools.com/Asp/prop_comm_commandtype.asp
;The CommandType property sets or returns a CommandTypeEnum value that defines the type of the Command object. Default is adCmdUnknown.
;If you do not specify the type, ADO will need to contact the provider to determine the type of the command. However, if you do specify the type, ADO will be able to process the command faster.
;http://www.vbforums.com/showthread.php?552665-Database-How-do-I-use-an-ADO-Command-object
;How do I use an ADO Command object?
;For statements that don't return records, execute the command specifying that it should not return any records
;this reduces the internal work, so makes it faster

;https://www.w3schools.com/asp/met_conn_execute.asp
;The Execute method executes a specified query, SQL statement, stored procedure, or provider-specific text.
;The results are stored in a new Recordset object if it is a row-returning query. A closed Recordset object will be returned if it is not a row-returning query.
;Note: The returned Recordset is always a read-only, forward-only Recordset!
;Tip: To create a Recordset with more functionality, first create a Recordset object. Set the desired properties, and then use the Recordset object's Open method to execute the query.

;How do I use an ADO Command object?
;http://www.vbforums.com/showthread.php?552665-Database-How-do-I-use-an-ADO-Command-object
;Unlike other ADO objects, you do not actually need to close it, but simply release the memory:
$cmd = 0
$rst = 0
$cn.Close ;Close the connection
$cn = 0 ;Release the connection object

Func _ErrADODB()
   Msgbox(0,"ADODB COM Error","We intercepted a COM Error !"      & @CRLF  & @CRLF & _
       "err.description is: "    & @TAB & $errADODB.description    & @CRLF & _
       "err.windescription:"     & @TAB & $errADODB.windescription & @CRLF & _
       "err.number is: "         & @TAB & hex($errADODB.number,8)  & @CRLF & _
       "err.lastdllerror is: "   & @TAB & $errADODB.lastdllerror   & @CRLF & _
       "err.scriptline is: "     & @TAB & $errADODB.scriptline     & @CRLF & _
       "err.source is: "         & @TAB & $errADODB.source         & @CRLF & _
       "err.helpfile is: "       & @TAB & $errADODB.helpfile       & @CRLF & _
       "err.helpcontext is: "    & @TAB & $errADODB.helpcontext, 5)

   Local $err = $errADODB.number
   If $err = 0 Then $err = -1


   $rst = 0
   $cmd = 0
   $cn.Close
   $cn = 0

   Exit
EndFunc

Func OnAutoItExit()
   $rst = 0 ; Release the recordset object
   $cmd = 0
   If IsObj($cn) Then
      If $cn.State > 0 Then $cn.Close ;adStateOpen Close the connection
      $cn = 0 ; Release the connection object
   EndIf
EndFunc

 

Edited by robertocm
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...