dotConnect for PostgreSQL Documentation
FetchAll Property
See Also  Example support@devart.com
Devart.Data.PostgreSql Namespace > PgSqlCommand Class : FetchAll Property

Gets or sets a value indicating whether the PgSqlDataReader object will request data from the server on execution ExecuteReader method.

Syntax

Visual Basic (Declaration) 
Public Property FetchAll As Boolean
C# 
public bool FetchAll {get; set;}

Property Value

true, if the PgSqlDataReader object will request data from the server on execution ExecuteReader; otherwise false. The default value is true.

Remarks

FetchAll property allows your application to reduce greatly size of used memory on processing big volume data. If set to true, memory will be allocated for all data returned by your SELECT. If FetchAll property is set to false, memory will be allocated only at most for hundred records and on retrieving next records previous rows will be rewritten.

Example

The following example fills two ListBox by data from the PgSqlDataReader. This sample demonstrates ability to navigate through the PgSqlDataReader several times when FetchAll property set to true.
C#csharpCopy Code
public void FillListBox()
{
  PgSqlCommand cmd;
  PgSqlDataReader reader;
  ListBox deptnoList, nameList;
  cmd = new PgSqlCommand("select deptno, dname from dept");
  cmd.FetchAll = true;
  reader = cmd.ExecuteReader();
  foreach (IDataRecord rec in reader) {
    deptnoList.Items.Add(rec["deptno"]);
  }
  foreach (IDataRecord rec in reader) {
    nameList.Items.Add(rec["dname"]);
  }
}
C#Visual BasicCopy Code
Public Sub FillListBox()
  Dim cmd As PgSqlCommand
  Dim reader As PgSqlDataReader
  Dim deptnoList As ListBox
  Dim nameList As ListBox
  cmd = New PgSqlCommand("select deptno, dname from dept")
  cmd.FetchAll = True
  reader = cmd.ExecuteReader()
  Dim rec As IDataRecord
  For Each rec In reader
    deptnoList.Items.Add(rec("deptno"))
  Next
  For Each rec In reader
    nameList.Items.Add(rec("dname"))
  Next
End Sub

Requirements

Platforms:Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7, Windows 8, Windows 10, Windows Server 2012 family.

See Also