ExecuteReader(CommandBehavior) Method
The following example creates a
BigcommerceCommand, 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 CreateBigcommerceDataReader(string mySelectQuery,string bigcommerceConnectionString)
{
BigcommerceConnection bigcommerceConnection = new BigcommerceConnection(bigcommerceConnectionString);
BigcommerceCommand bigcommerceCommand = new BigcommerceCommand(mySelectQuery, bigcommerceConnection);
bigcommerceCommand.Connection.Open();
BigcommerceDataReader bigcommerceReader = bigcommerceCommand.ExecuteReader(CommandBehavior.CloseConnection);
while(bigcommerceReader.Read())
{
Console.WriteLine(bigcommerceReader.GetString(0));
}
bigcommerceReader.Close();
}
Public Sub CreateBigcommerceDataReader(mySelectQuery As String, _
bigcommerceConnectionString As String)
Dim bigcommerceConnection As New BigcommerceConnection(bigcommerceConnectionString)
Dim bigcommerceCommand As New BigcommerceCommand(mySelectQuery, bigcommerceConnection)
bigcommerceCommand.Connection.Open()
Dim bigcommerceReader As BigcommerceDataReader = bigcommerceCommand.ExecuteReader(CommandBehavior.CloseConnection)
While bigcommerceReader.Read()
Console.WriteLine(bigcommerceReader.GetString(0))
End While
bigcommerceReader.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