Jump to content

Recommended Posts

Posted

Hi all,

first steps of requesting some data through sql from an iSeries DB2 table,

using the following code, connection with table seems to work, but when I want to retreive the data

I get an error:

coding:

$sqlCon = ObjCreate("ADODB.Connection")
$sqlCon.ConnectionString = "File Name=F:\UDL\B32903.UDL;"
$sqlCon.Open

; state connection      0 = N-OK
;                       1 = Ok
;                       2 = Connecting
$status = $sqlCon.State
MsgBox ( 0, "status", $status)

; request data
$strSQL = "Select * from GLAENEN/INSZ1; "
$result = $sqlCon.execute ($strSQL)

$sqlCon.Close

when running in scite it gives the following error:

>"F:\AUTOIT\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "F:\AUTOIT\testenvironment\sql.au3" /autoit3dir "F:\AUTOIT\AutoIt3" /UserParams    
+>15:22:55 Starting AutoIt3Wrapper v.1.8.3
>Running AU3Check (1.54.9.0)  from:F:\AUTOIT\AutoIt3
+>15:22:55 AU3Check ended.rc:0
>Running:(3.2.8.1):F:\AUTOIT\AutoIt3\autoit3.exe "F:\AUTOIT\testenvironment\sql.au3"    
F:\AUTOIT\testenvironment\sql.au3 (25) : ==> The requested action with this object has failed.: 
$result = $sqlCon.execute ($strSQL) 
$result = $sqlCon.execute ($strSQL)^ ERROR
->15:22:58 AutoIT3.exe ended.rc:1
+>15:22:59 AutoIt3Wrapper Finished
>Exit code: 1    Time: 4.253

anyone has any idea?

Posted

Thanks for the input guys,

just giving the next steps I executed that gave me the solution, maybe this can help someone who encounters the same problem.

1. I added an error handler that game me the extra information about the error.

2. I search this error upon the iseries environment which defined that the naming convention was wrong

3. Allthough within iseries I had to use GLAENEN/INSZ1 I replaced the / by a . which seemed the work.

As a final step I'll give the new correct code:

Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

$sqlCon = ObjCreate("ADODB.Connection")
$sqlCon.ConnectionString = "File Name=F:\UDL\B32903.UDL;"
$sqlCon.Open

; state connection      0 = N-OK
;                       1 = Ok
;                       2 = Connecting
$status = $sqlCon.State
MsgBox ( 0, "status", $status)

; request data
$strSQL = "Select F2 from glaenen.insz1"
$result = $sqlCon.execute ($strSQL)

$sqlCon.Close

; This is my custom defined error handler
Func MyErrFunc()

  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"      & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & hex($oMyError.number,8)  & @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 _
            )
            
    Local $err = $oMyError.number
    If $err = 0 Then $err = -1
    
    $g_eventerror = $err  ; to check for after this function returns
Endfunc

thx again,

a happy user ;-)

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...