dotConnect for BigCommerce Documentation
Devart.Data.Bigcommerce Namespace / BigcommerceDataReader Class
Members Example

In This Topic
    BigcommerceDataReader Class
    In This Topic
    Reads a forward-only stream of rows from BigCommerce.
    Syntax
    Remarks
    To create a BigcommerceDataReader, you must call the ExecuteReader method of the BigcommerceCommand object, rather than directly using a constructor.

    System.Data.Common.DbDataReader.IsClosed and RecordsAffected are the only properties that you can call after the BigcommerceDataReader is closed. In some cases, you must call Close before you can call RecordsAffected.

    Example
    The following example creates a BigcommerceConnection, a BigcommerceCommand, and a BigcommerceDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the BigcommerceDataReader, then the BigcommerceConnection.
    public void ReadMyData(string myConnString)  {
            BigcommerceConnection bigcommerceConnection = new BigcommerceConnection(myConnString);
            BigcommerceCommand bigcommerceCommand = (BigcommerceCommand)bigcommerceConnection.CreateCommand();
            bigcommerceCommand.CommandText = "SELECT id, firstname, lastname FROM customers";
            bigcommerceConnection.Open();
            BigcommerceDataReader bigcommerceReader = bigcommerceCommand.ExecuteReader();
            try {
                    // Always call Read before accessing data.
                    while (bigcommerceReader.Read()) {
                    Console.WriteLine(bigcommerceReader.GetInt32(0).ToString() + " " + 
                    bigcommerceReader.GetString(1) + " " + bigcommerceReader.GetString(2));
            }
            }
            finally {
                    // always call Close when done reading.
                    bigcommerceReader.Close();
    
                    // Close the connection when done with it.
                    bigcommerceConnection.Close();
            }
    }
    Public Sub ReadMyData(ByVal myConnString As String)
            Dim bigcommerceConnection As New BigcommerceConnection(myConnString)
            Dim bigcommerceCommand As BigcommerceCommand = bigcommerceConnection.CreateCommand()
                    bigcommerceCommand.CommandText = "SELECT id, firstname, lastname FROM customers"
            bigcommerceConnection.Open()
            Dim bigcommerceReader As BigcommerceDataReader = bigcommerceCommand.ExecuteReader()
            Try
                    ' Always call Read before accessing data.
                    While bigcommerceReader.Read()
                            Console.WriteLine(String.Concat(bigcommerceReader.GetInt32(0).ToString(), " ", _
                            bigcommerceReader.GetString(1), " ", bigcommerceReader.GetString(2)))
                    End While
            Finally
                    ' always call Close when done reading.
                    bigcommerceReader.Close()
    
                            ' Close the connection when done with it.
                            bigcommerceConnection.Close()
            End Try
    End Sub
    Inheritance Hierarchy

    System.Object
       System.MarshalByRefObject
          System.Data.Common.DbDataReader
             Devart.Common.DbDataReaderBase
                Devart.Data.SqlShimDataReader
                   Devart.Data.Bigcommerce.BigcommerceDataReader

    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