ExecuteReader(CommandBehavior) Method
The following example creates a
ExactTargetCommand, 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 CreateExactTargetDataReader(string mySelectQuery,string exactTargetConnectionString)
{
ExactTargetConnection exactTargetConnection = new ExactTargetConnection(exactTargetConnectionString);
ExactTargetCommand exactTargetCommand = new ExactTargetCommand(mySelectQuery, exactTargetConnection);
exactTargetCommand.Connection.Open();
ExactTargetDataReader exactTargetReader = exactTargetCommand.ExecuteReader(CommandBehavior.CloseConnection);
while(exactTargetReader.Read())
{
Console.WriteLine(exactTargetReader.GetString(0));
}
exactTargetReader.Close();
}
Public Sub CreateExactTargetDataReader(mySelectQuery As String, _
exactTargetConnectionString As String)
Dim exactTargetConnection As New ExactTargetConnection(exactTargetConnectionString)
Dim exactTargetCommand As New ExactTargetCommand(mySelectQuery, exactTargetConnection)
exactTargetCommand.Connection.Open()
Dim exactTargetReader As ExactTargetDataReader = exactTargetCommand.ExecuteReader(CommandBehavior.CloseConnection)
While exactTargetReader.Read()
Console.WriteLine(exactTargetReader.GetString(0))
End While
exactTargetReader.Close()
End Sub
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