Sign in to follow this  
Followers 0
vagabond719

Issue with .EOF function

4 posts in this topic

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)

Share this post


Link to post
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.

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

The .MoveFirst exactly what I needed. Thanks so much!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0