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

On this page
    SnowflakeCommand Class
    On this page
    Represents a SQL statement or stored procedure to execute against Snowflake.
    Syntax
    'Declaration
     
    Public Class SnowflakeCommand 
       Inherits Devart.Data.SnowflakeCommandBase
       Implements System.ComponentModel.IComponent, System.Data.IDbCommand, System.ICloneable, System.IDisposable 
    public class SnowflakeCommand : Devart.Data.SnowflakeCommandBase, System.ComponentModel.IComponent, System.Data.IDbCommand, System.ICloneable, System.IDisposable  
    Remarks
    The SnowflakeCommand class provides the following methods for executing commands against Snowflake:
    Item Description
    ExecuteReader Executes commands that return rows.
    Devart.Common.DbCommandBase.ExecutePageReader Returns a specific subset of rows when paging through the results of a query.
    ExecuteNonQuery Executes SQL commands such as INSERT, DELETE, UPDATE.
    ExecuteScalar Retrieves a single value (for example, an aggregate value) from a data source.

    If execution of the command results in a fatal SnowflakeException, the SnowflakeConnection may close. However, the user can reopen the connection and continue.

    Example
    The following example uses the ExecuteReader method of SnowflakeCommand, along with SnowflakeDataReader and SnowflakeConnection, to select rows from a table.
    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 = snowflakeCommand.ExecuteReader();
      try
      {
        while (snowflakeReader.Read())
        {
          Console.WriteLine(snowflakeReader.GetInt64(0) + ", " + snowflakeReader.GetString(1));
        }
      }
      finally
      {
      // always call Close when done reading.
      snowflakeReader.Close();
      // always call Close when done reading.
      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 = snowflakeCommand.ExecuteReader()
      Try
        While snowflakeReader.Read()
          Console.WriteLine(snowflakeReader.GetInt64(0) + ", " _
            + snowflakeReader.GetString(1))
        End While
      Finally
          ' always call Close when done reading.
          snowflakeReader.Close()
          ' always call Close when done with connection.
          snowflakeConnection.Close()
      End Try
    End Sub
    Inheritance Hierarchy

    System.Object
       System.MarshalByRefObject
          System.ComponentModel.Component
             System.Data.Common.DbCommand
                Devart.Common.DbCommandBase
                      Devart.Data.Snowflake.SnowflakeCommand

    See Also