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

Read Method (SqlShimDataReader)
Advances the SqlShimDataReader to the next record.
Syntax
'Declaration
 
Public Overrides Function Read() As Boolean
 

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.Magento.MagentoConnection is busy serving it until you call Close.

Example
The following example creates a Devart.Data.Magento.MagentoConnection, a Devart.Data.Magento.MagentoCommand, 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.Magento.MagentoConnection.
public void ReadMyData(string myConnString)
{
  string mySelectQuery = "SELECT customer_id, lastname FROM Customers";
  MagentoConnection adobe commerceConnection = new MagentoConnection(myConnString);
  MagentoCommand adobe commerceCommand = new MagentoCommand(mySelectQuery,adobe commerceConnection);
  adobe commerceConnection.Open();
  MagentoDataReader adobe commerceReader;
  adobe commerceReader = adobe commerceCommand.ExecuteReader();
  // Always call Read before accessing data.
  while (adobe commerceReader.Read()) {
    Console.WriteLine(adobe commerceReader.GetString(0) + ", " + adobe commerceReader.GetString(1));
  }
  // always call Close when done reading.
  adobe commerceReader.Close();
  // Close the connection when done with it.
  adobe commerceConnection.Close();
}
Public Sub ReadMyData(myConnString As String)
  Dim mySelectQuery As String = "SELECT customer_id, lastname FROM Customers"
  Dim adobe commerceConnection As New MagentoConnection(myConnString)
  Dim adobe commerceCommand As New MagentoCommand(mySelectQuery, adobe commerceConnection)
  adobe commerceConnection.Open()
  Dim adobe commerceReader As MagentoDataReader
  adobe commerceReader = adobe commerceCommand.ExecuteReader()
  ' Always call Read before accessing data.
  While adobe commerceReader.Read()
    Console.WriteLine(adobe commerceReader.GetString(0) + ", " _
      + adobe commerceReader.GetString(1))
  End While
  ' always call Close when done reading.
  adobe commerceReader.Close()
  ' Close the connection when done with it.
  adobe commerceConnection.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