Promotic

GetRows - method of the AdoRecordset object

Description:
Copies multiple records of the AdoRecordset object into an 2-dimensional array.
Syntax:
Array GetRows([Long nRows], [Variant vStart], [Variant aFields])
Parameters:
nRows[optional] (Long) Specifies the number of returned records. The default value is -1 = (adGetRowsRest) all remaining records.
vStart[optional] (Variant) Specifies the starting position (Bookmark). If not set, then the starting position will be the position of the current active record. If a valid Bookmark is defined, then it will be used as starting position. It is also possible to use standard numeric constants for defining the start position:
0 (default) - (adBookmarkCurrent) Current record.
1 - (adBookmarkFirst) First record.
2 - (adBookmarkLast) Last record.
aFields[optional] (Variant) A single name, or an array of names or ordinal positions of the fields in the record.
Return values:
Returns a Variant whose value is a 2-dimensional array.
Example1:
Reading the data in the form of 2-dimensional array. Request for the first 20 records of all columns from the current (first record) position.
JavaScriptVBScriptSelect and copy to clipboard

var oDb = pMe.Pm("/TestAdoDb");
var oRs = oDb.RsOpen("", "SELECT * FROM table1", "cursor:static;");
var aData = Pm.CreatePmArray();
if (oRs)
{
oRs.MoveFirst();
aData.LoadFromVbArray(oRs.GetRows(20, 0));
}
Example2:
Reading the data in the form of two dimensional array in the PmaAdo object ("/TestAdoDb"), that is connected to the database (see the DbOpen method), using the SQL query ("SELECT * FROM table1"). The resulting AdoRecordset object will be stored in the PmaAdo object with an unique identifier ("table1"), as (static) and (readonly). It is tested whether no error occurs and a valid AdoRecordset object was returned. The first 20 records from the current (first record) position are requested with two columns ("name", "value").
JavaScriptVBScriptSelect and copy to clipboard

var oDb = pMe.Pm("/TestAdoDb");
var oRs = oDb.RsOpen("", "SELECT * FROM table1", "cursor:static;");
var aColNames = Pm.CreatePmArray().Array1("name", "value");
var aData = Pm.CreatePmArray();
if (oRs)
{
oRs.MoveFirst();
aData.LoadFromVbArray(oRs.GetRows(20, 0, aColNames.SaveToVbArray()));
}
Example3:
Another syntax
JavaScriptSelect and copy to clipboard

var oDb = pMe.Pm("/TestAdoDb");
var oRs = oDb.RsOpen("", "SELECT * FROM table1", "cursor:static;");
var aColNames = Pm.CreatePmArray().Array1("name", "value");
if (oRs)
{
oRs.MoveFirst();
var aData = Pm.CallAxMethod("", oRs, "GetRows", 20, 0, aColNames.SaveToVbArray());
}

History:
Pm8.01.00: Created
PROMOTIC 9.0.17 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice