Jump to content

Issue with .EOF function


Recommended Posts

I am confused about something with my script below. It works as listed below. However I do not want to double query the database and when I try to assign $var2 = $var the array is corrected with the correct size but ends up being blank. Please let me know if I have done something incorrectly or if there is a different approach I should take.

#include <Array.au3>

$conn = ObjCreate( "ADODB.Connection" )

$DSN = "Driver={Microsoft ODBC for Oracle}; " & _

"CONNECTSTRING=(DESCRIPTION=" & _

"(ADDRESS=(PROTOCOL=TCP)" & _

"(HOST=MYSERVER)(PORT=5555))" & _

"(CONNECT_DATA=(SERVICE_NAME=ATPIDMP1)));uid=MYID;pwd=MYPW;"

$instancequery = "select * from SOME_TABLE where SOME_VALUE='SOMETHING' and OTHER_VALUE like 'SOMETHINGELSE'"

$conn.Open($DSN)

$var = $conn.execute($instancequery)

$var2 = $conn.execute($instancequery)

$columns = $var.fields.count

$row = 0

$countercolumn = 0

$counterrow = 0

;$var2 = $var

while Not $var2.EOF

$row = $row + 1

$var2.MoveNext

WEnd

Global $array[$row][$columns]

While Not $var.EOF

For $field2 In $var.fields

$array[$counterrow][$countercolumn] = $field2.value

$countercolumn += 1

Next

$var.MoveNext

$counterrow += 1

$countercolumn = 0

WEnd

$conn.close

_ArrayDisplay($array)

Link to comment
Share on other sites

Use the RecordCount property of the recordset object to get the number of records.

Or use method .MoveFirst to move to the frist record of the recordset and process the recordset again.

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

 

Link to comment
Share on other sites

To enhance performance I would use the RecordCount property to create the array and then process the recordset and fill the array. This way you have to loop through the recordset only once!

Edited by water

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

 

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