Jump to content

Recommended Posts

Posted

Hello, 

I can read HFSQL database (took exemple here https://www.autoitscript.fr/forum/viewtopic.php?t=14596)

I can 'Update' the table (the result is ok) BUT it doesn't give me the 'RecordsAffected' value correct  as describe here: https://www.w3schools.com/asp/met_comm_execute.asp#commandtypeenum
Any Idea why ?

Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; Initialize a COM error handler
Global $ErrorCom

Global Const $PROVIDER = "PCSoft.HFSQL"
Global Const $SERVER = '\\myserver\' 
Global Const $WDDPATH = 'path\file.wdd'
Global $sPathDsn = $SERVER & 'iprefaceE\TEST\TEST\TEST24\'


$sQuery = "update produit set typpr = 'USA' where typpr = 'USB'"
;~ $sQuery = "update produit set typpr = 'USB' where typpr = 'USA'"
$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")     ; Initialize a COM error handler

Global $adoCon = ObjCreate("ADODB.Connection")
Global $adoCmd = ObjCreate("ADODB.Command")


$dsn = "Provider=" & $PROVIDER & ";Data Source=" & $SERVER & $WDDPATH & ";Initial Catalog=" & $sPathDsn & ";"
ConsoleWrite($dsn & @CRLF)
$adoCon.ConnectionString = $dsn
$adoCon.CursorLocation = 3     ;A indiquer pour PC Soft sinon ne fonctionne pas
$adoCon.Open

; Execute the SQL query
$adoCmd.ActiveConnection = $adoCon
$adoCmd.CommandText = $sQuery

Local $RecordsAffected = -1
$adoCmd.Execute($RecordsAffected, $sQuery)

; Output the number of affected rows
ConsoleWrite("Number of rows affected: " & $RecordsAffected & @CRLF)


$adoCon.Close

Func MyErrFunc() ; error handler
;~  MsgBox(16 + 262144, 'Error',
    ConsoleWrite(@CRLF & "We intercepted a COM Error !" & @CRLF & @CRLF & _
            "err.description is: " & @TAB & $oMyError.description & @CRLF & _
            "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
            "err.number is: " & @TAB & "0x" & Hex($oMyError.number, 8) & @CRLF & _
            "err.number is: " & @TAB & $oMyError.number & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
            "err.source is: " & @TAB & $oMyError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oMyError.helpcontext & @CRLF & _
            "err.retcode is: " & @TAB & "0x" & Hex($oMyError.retcode) & @CRLF & _
            "err.retcode is: " & @TAB & $oMyError.retcode & @CRLF & @CRLF)
    $oMyError = ''
    $ErrorCom = 1
EndFunc   ;==>MyErrFunc

I search a lot but didn't find anything!

Any help appreciated !

Cramaboule

  • Solution
Posted

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:

  Reveal hidden contents

Signature last update: 2023-04-24

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
  • Recently Browsing   0 members

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