Controls the number of rows to be returned to client in a single fetch request. This value would override any NumRowsOnFtech value set in db2dsdriver.cfg
[Visual Basic]
Public Property BlockForNRows As Integer
[C#]
public int BlockForNRows {get; set;}
[C++]
public: __property int get_BlockForNRows();
public: __property void set_BlockForNRows(int);
[JScript]
public function get BlockForNRows() : int;
public function set BlockForNRows(int);
A positive integer n, where rows of data will be returned in a single fetch request to the client.
Exception type | Condition |
---|---|
InvalidArgumentException | The property value is a negative number. |
InvalidOperationException | The property value is set for non Forward-only cursors. |
The BlockForNRows setting will be silently ignored when reading data from a page reader.
Using BlockForNRows DB2Command property
DB2Connection connection = new DB2Connection(connectionString);
DB2Command cmd = connection .CreateCommand();
cmd.BlockForNRows=10;
cmd.CommandText = "SELECT c1,c2 FROM T1";
DB2DataReader reader=cmd.ExecuteReader();
while(reader.Read())
{
//Process the records
}
Using db2dsdriver.cfg keyword
<configuration>
<dsncollection>
<dsn alias="alias1" name="db1" host="host1" port="50000">
<parameter name="NumRowsOnFetch" value="10"/>
</dsn>
</dsncollection>
</configuration>
DB2Connection connection = new DB2Connection("database=alias1;...");
DB2Command cmd = connection.CreateCommand();
cmd.CommandText = "SELECT c1,c2 FROM T1";
DB2DataReader reader=cmd.ExecuteReader();
while(reader.Read())
{
//Process the records
...
}