Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems

 

ADO Recordset Object MaxRecords Property

The maximum number of records to return to a recordset from a query.

MaxRecords Property Return Values

Sets or returns a Long value. Default is zero (no limit).

MaxRecords Property Remarks

Use the MaxRecords property to limit the number of records the provider returns from the data source. The default setting of this property is zero, which means the provider returns all requested records. The MaxRecords property is read/write when the recordset is closed and read-only when it is open.

MaxRecords Property Example

This Visual Basic example uses the MaxRecords property to open a recordset containing the 10 most expensive titles in the Titles table.

Public Sub MaxRecordsX()

Dim rstTemp As ADODB.Recordset

Dim strCnn As String

` Open recordset containing the 10 most expensive

` titles in the Titles table.

strCnn = "driver={SQL Server};server=srv;" & _

"uid=sa;pwd=;database=pubs"

Set rstTemp = New ADODB.Recordset

rstTemp.MaxRecords = 10

rstTemp.Open "SELECT Title, Price FROM Titles " & _

"ORDER BY Price DESC", strCnn, , , adCmdText

` Display the contents of the recordset.

Debug.Print "Top Ten Titles by Price:"

Do While Not rstTemp.EOF

Debug.Print " " & rstTemp!Title & " - " & rstTemp!Price

rstTemp.MoveNext

Loop

rstTemp.Close

End Sub

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.