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

On this page
    Read Method (SqlShimDataReader)
    On this page
    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.Snowflake.SnowflakeConnection is busy serving it until you call Close.

    Example
    The following example creates a Devart.Data.Snowflake.SnowflakeConnection, a Devart.Data.Snowflake.SnowflakeCommand, 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.Snowflake.SnowflakeConnection.
    public void ReadMyData(string myConnString)
    {
      string mySelectQuery = "SELECT id, first_name FROM your_database.your_schema.employees";
      SnowflakeConnection snowflakeConnection = new SnowflakeConnection(myConnString);
      SnowflakeCommand snowflakeCommand = new SnowflakeCommand(mySelectQuery,snowflakeConnection);
      snowflakeConnection.Open();
      SnowflakeDataReader snowflakeReader;
      snowflakeReader = snowflakeCommand.ExecuteReader();
      // Always call Read before accessing data.
      while (snowflakeReader.Read()) {
        Console.WriteLine(snowflakeReader.GetString(0) + ", " + snowflakeReader.GetString(1));
      }
      // always call Close when done reading.
      snowflakeReader.Close();
      // Close the connection when done with it.
      snowflakeConnection.Close();
    }
    Public Sub ReadMyData(myConnString As String)
      Dim mySelectQuery As String = "SELECT id, first_name FROM your_database.your_schema.employees"
      Dim snowflakeConnection As New SnowflakeConnection(myConnString)
      Dim snowflakeCommand As New SnowflakeCommand(mySelectQuery, snowflakeConnection)
      snowflakeConnection.Open()
      Dim snowflakeReader As SnowflakeDataReader
      snowflakeReader = snowflakeCommand.ExecuteReader()
      ' Always call Read before accessing data.
      While snowflakeReader.Read()
        Console.WriteLine(snowflakeReader.GetString(0) + ", " _
          + snowflakeReader.GetString(1))
      End While
      ' always call Close when done reading.
      snowflakeReader.Close()
      ' Close the connection when done with it.
      snowflakeConnection.Close()
    End Sub
    See Also