Jump to content

Recommended Posts

Posted

Hello,

I hope you can help me with the following problem:

I am trying to retrieve data from a database table with a very simple query, I have the connection to the ADODB and to the server, but when I try to save the executed query into a variable and then get the rows by using the .GetRows() method, i get the error message "Variable must be of type 'Object' ".

Below you can see the code that is used to get the data.

Func _GetData()
    MsgBox(0,"","Get Dat function")
    ;"ARServerPort=3003;DSN=AR System ODBC Data Source;ARServer=DESQLAPPSP01;UID=RZURJAC;PWD=test232;SERVER=NotTheServer;"
    ;$sDriver, $sDatabase, $ARServer, $ARServerPort, $sUsername = "", $sPassword = "", $fAuthMode = 1
    $driver = "{AR System ODBC Driver}"
    $DSN = "AR System ODBC Data Source"
    $ARServer = "DESQLAPPSP01"
    $ARServerPort = "3003"
    $user = "RZURJAC"
    $password = "test232"

    $SQLConn = _SQLConnect($driver,$DSN,$ARServer,$ARServerPort, $user, $password, 1)

    $query = 'SELECT Sammelgang_DB.Short_Description, Sammelgang_DB.Status, Sammelgang_DB.Wunschtermin FROM Sammelgang_DB Sammelgang_DB WHERE (Sammelgang_DB.Status=' & "'Angefordert' ) ORDER BY " & '"Sammelgang_DB".Wunschtermin'
    $ArrayResult = _SQLQuery($SQLConn, $query)
    _ArrayDisplay($ArrayResult)
    _SQLDisconnect($SQLConn)
EndFunc
Func _SQLConnect($sDriver, $sDatabase, $ARServer, $ARServerPort, $sUsername = "", $sPassword = "", $fAuthMode = 1)
    MsgBox(0,"","In Connection")
    $oConn = ObjCreate("ADODB.Connection")
    If NOT IsObj($oConn) Then
        MsgBox(0,"","Failure in ADODB Conenction")
        Return SetError(3, 0, 0)
    EndIf
    If $fAuthMode Then $oConn.Open ("DRIVER= " & $sDriver & ";DSN= " & $sDatabase & ";ARServer=" & $ARServer & ";ARServerPort=" & $ARServerPort & ";UID= " & $sUsername & ";PWD=" & $sPassword & ";ARAuthentication=;SERVER=NotTheServer")
    If @error Then
        MsgBox(0,"","Failure in Database" & @error)
        Return SetError(1, 0, 0)
    EndIf
    MsgBox(0,"","It worked")
    Return $oConn
EndFunc   ;==>_SQLConnect
Func _SQLQuery($oConn, $sQuery)
    If IsObj($oConn) Then
        MsgBox(0,"","Its an object")
        MsgBox(0,"",$sQuery)
        $return = $oConn.Execute($sQuery)
        $ArrayReturn = $return.GetRows()
        _ArrayDisplay($ArrayReturn)
    EndIf
    Return SetError(1, 0, 0)
EndFunc ;==>_SQLQuery

In the function _SQLQuery(), it gets into the if sentence, but it stops at $ArrayReturn = $return.GetRows() and tells me that the variable is not an object.

Thank you for your help...

Posted

You need to add some error checking. Either check the value of @error after a function call or add a COM error handler.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Well I just did an @error checking with a MsgBox showing me what the @error is, all I can get from this is that the execute method doesnt seem to work

Posted

In this case I suggest to add a COM error handler because you get detailed error information. An example can be found in the help file for ObjEvent.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted
err.number is: 0x80020009
err.windescription: Exception occurred.
 
err.description is: Driver][iSAM]No data found
err.source is: Microsoft OLE DB Provider for ODBC Drivers
err.helpfile is:
err.helpcontext is: 0
err.lastdllerror is: 0
err.scriptline is: 69
err.retcode is: 0x80004005
 
This is the Error Message I get with the errorHandler
Posted

You are sure that the query should return some data?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

I copied it from a friends program where it worked perfectly. I also looked at his code in case he has done something different, but he said that my code is good, so I am absolutely not sure what it might be...

Posted

Can you try this query as a test?

 

$query = "SELECT Sammelgang_DB.Short_Description, Sammelgang_DB.Status, Sammelgang_DB.Wunschtermin FROM Sammelgang_DB WHERE Sammelgang_DB.Status LIKE 'Angefordert' ORDER BY Sammelgang_DB.Wunschtermin"
Posted

Glad it was that easy!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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
×
×
  • Create New...