DB2®ResultSet.ReadLast Method
Moves the DB2ResultSet to the last record, if the cursor is scrollable.
- Namespace:
IBM.Data.DB2- Assembly:
IBM.Data.DB2(inIBM.Data.DB2.dll)
Syntax
[Visual Basic]
Public Function ReadLast As Boolean
[C#]
public bool ReadLast ()
[C++]
public:
bool ReadLast ()
[JScript]
public function ReadLast () : Boolean
Return value
true if
the newly assumed position has a record (regardless if it was deleted);
otherwise, false.
Remarks
The default position of the DB2ResultSet is before the first record. Therefore, you must call Read, ReadFirst, ReadLast, or ReadAbsolute before any data.
Example
[C#] The following example demonstrates how to determine if the DB2ResultSet instance is scrollable, and then how to read the last row in the result set.
[C#]
public static string getSalesData(DB2Connection conn)
{
string salesQuery = "SELECT * FROM SALES";
string salesData = "";
DB2Command cmd = new DB2Command(salesQuery, conn);
DB2ResultSet salesRS = cmd.ExecuteResultSet(
DB2ResultSetOptions.Scrollable |
DB2ResultSetOptions.Sensitive |
DB2ResultSetOptions.SkipDeleted);
if (salesRS.Scrollable)
{
if (salesRS.ReadLast())
{
salesData = salesRS.GetDB2Date(0).ToString();
salesData += ", " + salesRS.GetDB2String(1).ToString();
salesData += ", " + salesRS.GetDB2String(2).ToString();
salesData += ", " + salesRS.GetDB2Int32(3).ToString();
}
}
return salesData;
}