dotConnect for Snowflake Documentation
Devart.Data.Snowflake Namespace / SnowflakeDataAdapter Class / SelectCommand Property
Example

On this page
    SelectCommand Property
    On this page
    Gets or sets a Snowflake statement used to select records in the data source.
    Syntax
    'Declaration
     
    Public Shadows Property SelectCommand As SnowflakeCommand
    public new SnowflakeCommand SelectCommand {get; set;}

    Property Value

    A SnowflakeCommand that is used during a fill operation to select records from the data source for placement in the System.Data.DataSet.
    Remarks
    When SelectCommand is assigned to a previously created SnowflakeCommand, the SnowflakeCommand is not cloned. Instead, the SelectCommand maintains a reference to the previously created SnowflakeCommand object.

    If SelectCommand does not return any rows, no tables are added to the System.Data.DataSet, and no exception is raised.

    Example
    The following example creates a SnowflakeDataAdapter, sets some of its properties, retrieves data from a table, and displays it.
    public void CreateDataAdapter(SnowflakeConnection snowflakeConnection)
    {
      SnowflakeDataAdapter myAdapter = new SnowflakeDataAdapter();
      myAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
      DataSet myDataSet = new DataSet();
      myAdapter.SelectCommand = new SnowflakeCommand("SELECT id, first_name FROM your_database.your_schema.employees", snowflakeConnection);
      myAdapter.Fill(myDataSet,"your_database.your_schema.employees");
      //Get all data from all tables within the dataset
      foreach(DataTable myTable in myDataSet.Tables)
      {
        foreach(DataRow myRow in myTable.Rows)
        {
          foreach (DataColumn myColumn in myTable.Columns)
          {
            Console.Write(myRow[myColumn]+"\t");
          }
          Console.WriteLine();
        }
        Console.WriteLine();
      }
    }
    Public Sub CreateDataAdapter(ByVal snowflakeConnection As SnowflakeConnection)
      Dim myAdapter As SnowflakeDataAdapter = New SnowflakeDataAdapter
      myAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
      Dim myDataSet As DataSet = New DataSet
      myAdapter.SelectCommand = New SnowflakeCommand("SELECT id, first_name FROM your_database.your_schema.employees", snowflakeConnection)
      myAdapter.Fill(myDataSet, "your_database.your_schema.employees")
      Dim myTable As DataTable
      Dim myRow As DataRow
      Dim myColumn As DataColumn
      ' Get all data from all tables within the dataset
      For Each myTable In myDataSet.Tables
        For Each myRow In myTable.Rows
          For Each myColumn In myTable.Columns
            Console.Write(myRow(myColumn) & Chr(9))
          Next myColumn
          Console.WriteLine()
        Next myRow
        Console.WriteLine()
      Next myTable
    End Sub
    See Also