ExecuteReader(CommandBehavior) Method
The following example creates a
MailChimpCommand, 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 CreateMailChimpDataReader(string mySelectQuery,string mailChimpConnectionString)
{
MailChimpConnection mailChimpConnection = new MailChimpConnection(mailChimpConnectionString);
MailChimpCommand mailChimpCommand = new MailChimpCommand(mySelectQuery, mailChimpConnection);
mailChimpCommand.Connection.Open();
MailChimpDataReader mailChimpReader = mailChimpCommand.ExecuteReader(CommandBehavior.CloseConnection);
while(mailChimpReader.Read())
{
Console.WriteLine(mailChimpReader.GetString(0));
}
mailChimpReader.Close();
} |
|
|---|
Public Sub CreateMailChimpDataReader(mySelectQuery As String, _
mailChimpConnectionString As String)
Dim mailChimpConnection As New MailChimpConnection(mailChimpConnectionString)
Dim mailChimpCommand As New MailChimpCommand(mySelectQuery, mailChimpConnection)
mailChimpCommand.Connection.Open()
Dim mailChimpReader As MailChimpDataReader = mailChimpCommand.ExecuteReader(CommandBehavior.CloseConnection)
While mailChimpReader.Read()
Console.WriteLine(mailChimpReader.GetString(0))
End While
mailChimpReader.Close()
End Sub |