dotConnect for Google BigQuery Documentation
Devart.Data.BigQuery Namespace / BigQueryDataAdapter Class / SelectCommand Property
Example

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

    Property Value

    A BigQueryCommand 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 BigQueryCommand, the BigQueryCommand is not cloned. Instead, the SelectCommand maintains a reference to the previously created BigQueryCommand 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 BigQueryDataAdapter, sets some of its properties, retrieves data from a table, and displays it.
    public void CreateDataAdapter(BigQueryConnection bigQueryConnection)
    {
      BigQueryDataAdapter myAdapter = new BigQueryDataAdapter();
      myAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
      DataSet myDataSet = new DataSet();
      myAdapter.SelectCommand = new BigQueryCommand("SELECT id, first_name FROM your_project.your_dataset.employees", bigQueryConnection);
      myAdapter.Fill(myDataSet,"your_project.your_dataset.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 bigQueryConnection As BigQueryConnection)
      Dim myAdapter As BigQueryDataAdapter = New BigQueryDataAdapter
      myAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
      Dim myDataSet As DataSet = New DataSet
      myAdapter.SelectCommand = New BigQueryCommand("SELECT id, first_name FROM your_project.your_dataset.employees", bigQueryConnection)
      myAdapter.Fill(myDataSet, "your_project.your_dataset.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