dotConnect for DB2 Documentation
Devart.Data.DB2 Namespace / DB2Command Class / ExecuteReader Method / ExecuteReader(CommandBehavior) Method
One of the System.Data.CommandBehavior values.
Example

ExecuteReader(CommandBehavior) Method
Sends the CommandText to the Connection, and builds a DB2DataReader using one of the System.Data.CommandBehavior values.
Syntax
'Declaration
 
Public Overloads Shadows Function ExecuteReader( _
   ByVal behavior As CommandBehavior _
) As DB2DataReader
 

Parameters

behavior
One of the System.Data.CommandBehavior values.

Return Value

A DB2DataReader object.
Example
The following example creates a DB2Command, then executes it by passing a string that is SQL SELECT statement, and a string to use to connect to the data source. The System.Data.CommandBehavior is then set to CloseConnection.
public void CreateDB2DataReader(string mySelectQuery,string db2ConnectionString)
{
  DB2Connection db2Connection = new DB2Connection(db2ConnectionString);
  DB2Command db2Command = new DB2Command(mySelectQuery, db2Connection);
  db2Command.Connection.Open();
  DB2DataReader db2Reader = db2Command.ExecuteReader(CommandBehavior.CloseConnection);
  while(db2Reader.Read())
  {
    Console.WriteLine(db2Reader.GetString(0));
  }
  db2Reader.Close();
}
Public Sub CreateDB2DataReader(mySelectQuery As String, _
db2ConnectionString As String)
  Dim db2Connection As New DB2Connection(db2ConnectionString)
  Dim db2Command As New DB2Command(mySelectQuery, db2Connection)
  db2Command.Connection.Open()
  Dim db2Reader As DB2DataReader = db2Command.ExecuteReader(CommandBehavior.CloseConnection)
  While db2Reader.Read()
    Console.WriteLine(db2Reader.GetString(0))
  End While
  db2Reader.Close()
End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also