Microsoft KB Archive/198528

= FIX: GetRows Method of ADO Object Returns Incorrect Value =

Article ID: 198528

Article Last Modified on 3/14/2005

-

APPLIES TO


 * Microsoft ActiveX Data Objects 2.0
 * Microsoft ActiveX Data Objects 2.1
 * Microsoft ActiveX Data Objects 2.5

-



This article was previously published under Q198528



SYMPTOMS
The GetRows method of an ADO recordset object moves the record pointer forward one row too many when dealing with greater than 100 rows. GetRows simply places the records from the recordset object into an array. After calling GetRows, the next unread record is supposed to become the current record. When getting 1000 rows, for example, the next record should be 1001, but instead it places the user on record 1002.



RESOLUTION
The user can call 100 records or less with GetRows rather then greater than 100.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This behavior is fixed in Active Data Objects version 2.1 and later.



Steps to Reproduce Behavior
 Create a Standard EXE project in Visual Basic. Form1 is created by default. Add a CommandButton to form1.  Add the following code to the click event of the command button. This assumes that you have a DSN called "Test" which points to an Access table called "test1" with greater then 1000 records. (Create table test1 in an access database with one column c1 (number)-Insert more than thousand records into the same): Dim conn As Object, rs As Object Dim myArray As Variant Set conn = CreateObject("ADODB.Connection") conn.open ("DSN=Test") Set rs = conn.Execute("select * from test1")

myArray = rs.getrows(1000) ' uncomment the following line to receive correct value in MsgBox. 'myArray = rs.getrows(100)

MsgBox rs("c1") rs.Close Set rs = Nothing conn.Close Set conn = Nothing 

Note that the MsgBox displays 1002 when it should display 1001, which is the next record after 1000.

Keywords: kbbug kbfix kbmdac250fix kbado210fix KB198528

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.