ExactTargetDataReader Class
Reads a forward-only stream of rows from Salesforce Marketing Cloud.
The following example creates a
ExactTargetConnection, a
ExactTargetCommand, and a
ExactTargetDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the
ExactTargetDataReader, then the
ExactTargetConnection.
|
|---|
public void ReadMyData(string myConnString) {
ExactTargetConnection exactTargetConnection = new ExactTargetConnection(myConnString);
ExactTargetCommand exactTargetCommand = (ExactTargetCommand)exactTargetConnection.CreateCommand();
exactTargetCommand.CommandText = "SELECT ID, Name, Subject FROM Email";
exactTargetConnection.Open();
ExactTargetDataReader exactTargetReader = exactTargetCommand.ExecuteReader();
try {
// Always call Read before accessing data.
while (exactTargetReader.Read()) {
Console.WriteLine(exactTargetReader.GetInt32(0).ToString() + " " +
exactTargetReader.GetString(1) + " " + exactTargetReader.GetString(2));
}
}
finally {
// always call Close when done reading.
exactTargetReader.Close();
// Close the connection when done with it.
exactTargetConnection.Close();
}
} |
|
|---|
Public Sub ReadMyData(ByVal myConnString As String)
Dim exactTargetConnection As New ExactTargetConnection(myConnString)
Dim exactTargetCommand As ExactTargetCommand = exactTargetConnection.CreateCommand()
exactTargetCommand.CommandText = "SELECT ID, Name, Subject FROM Email"
exactTargetConnection.Open()
Dim exactTargetReader As ExactTargetDataReader = exactTargetCommand.ExecuteReader()
Try
' Always call Read before accessing data.
While exactTargetReader.Read()
Console.WriteLine(String.Concat(exactTargetReader.GetInt32(0).ToString(), " ", _
exactTargetReader.GetString(1), " ", exactTargetReader.GetString(2)))
End While
Finally
' always call Close when done reading.
exactTargetReader.Close()
' Close the connection when done with it.
exactTargetConnection.Close()
End Try
End Sub |