dotConnect for Snowflake Documentation
Devart.Data.Snowflake Namespace / SnowflakeDataReader Class
Members Example

On this page
    SnowflakeDataReader Class
    On this page
    Reads a forward-only stream of rows from Snowflake.
    Syntax
    Remarks
    To create a SnowflakeDataReader, you must call the ExecuteReader method of the SnowflakeCommand object, rather than directly using a constructor.

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

    Example
    The following example creates a SnowflakeConnection, a SnowflakeCommand, and a SnowflakeDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the SnowflakeDataReader, then the SnowflakeConnection.
    public void ReadMyData(string myConnString)  {
            SnowflakeConnection snowflakeConnection = new SnowflakeConnection(myConnString);
            SnowflakeCommand snowflakeCommand = (SnowflakeCommand)snowflakeConnection.CreateCommand();
            snowflakeCommand.CommandText = "SELECT id, first_name, last_name FROM your_database.your_schema.employees";
            snowflakeConnection.Open();
            SnowflakeDataReader snowflakeReader = snowflakeCommand.ExecuteReader();
            try {
                    // Always call Read before accessing data.
                    while (snowflakeReader.Read()) {
                    Console.WriteLine(snowflakeReader.GetInt64(0) + " " + 
                    snowflakeReader.GetString(1) + " " + snowflakeReader.GetString(2));
            }
            }
            finally {
                    // always call Close when done reading.
                    snowflakeReader.Close();
    
                    // Close the connection when done with it.
                    snowflakeConnection.Close();
            }
    }
    Public Sub ReadMyData(ByVal myConnString As String)
            Dim snowflakeConnection As New SnowflakeConnection(myConnString)
            Dim snowflakeCommand As SnowflakeCommand = snowflakeConnection.CreateCommand()
                    snowflakeCommand.CommandText = "SELECT id, first_name, last_name FROM your_database.your_schema.employees"
            snowflakeConnection.Open()
            Dim snowflakeReader As SnowflakeDataReader = snowflakeCommand.ExecuteReader()
            Try
                    ' Always call Read before accessing data.
                    While snowflakeReader.Read()
                            Console.WriteLine(String.Concat(snowflakeReader.GetInt64(0), " ", _
                            snowflakeReader.GetString(1), " ", snowflakeReader.GetString(2)))
                    End While
            Finally
                    ' always call Close when done reading.
                    snowflakeReader.Close()
    
                            ' Close the connection when done with it.
                            snowflakeConnection.Close()
            End Try
    End Sub
    Inheritance Hierarchy

    System.Object
       System.MarshalByRefObject
          System.Data.Common.DbDataReader
             Devart.Common.DbDataReaderBase
                Devart.Data.SqlShimDataReader
                   Devart.Data.Snowflake.SnowflakeDataReader

    See Also