DB2ResultSet Class
The
class provides the ability to
scroll through a bindable stream of rows that are returned from a
database. You can also insert, update, and delete rows in the DB2ResultSet object.DB2
ResultSet
- Namespace:
IBM.Data
DB2
- Assembly:
IBM.Data
DB2
(inIBM.Data
DB2
.dll
)
Inheritance hierarchy
System.Object
System.MarshalByRefObject
IBM.Data.DB2.DB2ResultSet
Syntax
[Visual Basic]
Public Class DB2
ResultSet
[C#]
public class DB2
ResultSet
[C++]
public class DB2
ResultSet
[JScript]
public class DB2
ResultSet
Data server restrictions
- Db2® servers
- Db2 for z/OS® servers, with the Db2 Connect license.
- Informix® database server.
The scrollable DB2ResultSet class with dynamic cursor is only supported on database servers that support the dynamic cursor.
- CursorType
- Scrollable
- Updatable
- Sensitive
- SkipDeleted
Remarks
The DB2ResultSet class is used to access streams of rows that are generated from executing a statement. The DB2ResultSet class provides a flexible alternative to using the DB2DataReader class for reading data from a database server. Use of the DB2ResultSet class provides a high-performance alternative to using a DataSet with the DB2DataAdapter class for the binding of application controls to a database server.
Creating a DB2ResultSet object is similar to creating a DB2DataAdapter object: from a connected DB2Command object, the DB2Command.ExecuteResultSet method returns a DB2ResultSet object. You can call the DB2Command.ExecuteResultSet method with specific option to determine the properties of a DB2ResultSet object.
Example
[C#] The following example demonstrates how to read data from a scrollable DB2ResultSet that is sensitive to inserts, updates, and deletes from other applications.
[C#]
public static string getSalesData(DB2
Connection conn)
{
string salesQuery = "SELECT * FROM SALES";
string salesData = "";
DB2
Command cmd = new DB2
Command(salesQuery, conn);
DB2
ResultSet salesRS = cmd.ExecuteResultSet(
DB2
ResultSetOptions.Scrollable |
DB2
ResultSetOptions.Sensitive |
DB2
ResultSetOptions.SkipDeleted);
if (salesRS.Scrollable)
{
if (salesRS.ReadLast())
{
salesData = salesRS.GetDB2
Date(0).ToString();
salesData += ", " + salesRS.GetDB2
String(1).ToString();
salesData += ", " + salesRS.GetDB2
String(2).ToString();
salesData += ", " + salesRS.GetDB2
Int32(3).ToString();
}
}
return salesData;
}
Thread safety
Any public static (Shared
in Visual
Basic) members of this type are safe for multithreaded operations.