dotConnect for BigCommerce Documentation
Devart.Data Namespace / SqlShimDataReader Class / Read Method
Example

In This Topic
    Read Method (SqlShimDataReader)
    In This Topic
    Advances the SqlShimDataReader to the next record.
    Syntax
    'Declaration
     
    Public Overrides Function Read() As Boolean
    public override bool Read()

    Return Value

    true if there are more rows; otherwise, false.
    Remarks
    The default position of the SqlShimDataReader is prior to the first record. Therefore, you must call Read to begin accessing any data.

    While the SqlShimDataReader is in use, the associated Devart.Data.Bigcommerce.BigcommerceConnection is busy serving it until you call Close.

    Example
    The following example creates a Devart.Data.Bigcommerce.BigcommerceConnection, a Devart.Data.Bigcommerce.BigcommerceCommand, and a SqlShimDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the SqlShimDataReader, then the Devart.Data.Bigcommerce.BigcommerceConnection.
    public void ReadMyData(string myConnString)
    {
      string mySelectQuery = "SELECT id, lastname FROM customers";
      BigcommerceConnection bigcommerceConnection = new BigcommerceConnection(myConnString);
      BigcommerceCommand bigcommerceCommand = new BigcommerceCommand(mySelectQuery,bigcommerceConnection);
      bigcommerceConnection.Open();
      BigcommerceDataReader bigcommerceReader;
      bigcommerceReader = bigcommerceCommand.ExecuteReader();
      // Always call Read before accessing data.
      while (bigcommerceReader.Read()) {
        Console.WriteLine(bigcommerceReader.GetString(0) + ", " + bigcommerceReader.GetString(1));
      }
      // always call Close when done reading.
      bigcommerceReader.Close();
      // Close the connection when done with it.
      bigcommerceConnection.Close();
    }
    Public Sub ReadMyData(myConnString As String)
      Dim mySelectQuery As String = "SELECT id, lastname FROM customers"
      Dim bigcommerceConnection As New BigcommerceConnection(myConnString)
      Dim bigcommerceCommand As New BigcommerceCommand(mySelectQuery, bigcommerceConnection)
      bigcommerceConnection.Open()
      Dim bigcommerceReader As BigcommerceDataReader
      bigcommerceReader = bigcommerceCommand.ExecuteReader()
      ' Always call Read before accessing data.
      While bigcommerceReader.Read()
        Console.WriteLine(bigcommerceReader.GetString(0) + ", " _
          + bigcommerceReader.GetString(1))
      End While
      ' always call Close when done reading.
      bigcommerceReader.Close()
      ' Close the connection when done with it.
      bigcommerceConnection.Close()
    End Sub
    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