dotConnect for Google BigQuery Documentation
Devart.Data.BigQuery Namespace / BigQueryCommand Class
Members Example

On this page
    BigQueryCommand Class
    On this page
    Represents a SQL statement or stored procedure to execute against Google BigQuery.
    Syntax
    'Declaration
     
    Public Class BigQueryCommand 
       Inherits Devart.Data.BigQueryCommandBase
       Implements System.ComponentModel.IComponent, System.Data.IDbCommand, System.ICloneable, System.IDisposable 
    public class BigQueryCommand : Devart.Data.BigQueryCommandBase, System.ComponentModel.IComponent, System.Data.IDbCommand, System.ICloneable, System.IDisposable  
    Remarks
    The BigQueryCommand class provides the following methods for executing commands against Google BigQuery:
    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 BigQueryException, the BigQueryConnection may close. However, the user can reopen the connection and continue.

    Example
    The following example uses the ExecuteReader method of BigQueryCommand, along with BigQueryDataReader and BigQueryConnection, to select rows from a table.
    public void ReadMyData(string myConnString)
    {
      string mySelectQuery = "SELECT id, first_name FROM your_project.your_dataset.employees";
      BigQueryConnection bigQueryConnection = new BigQueryConnection(myConnString);
      BigQueryCommand bigQueryCommand = new BigQueryCommand(mySelectQuery,bigQueryConnection);
      bigQueryConnection.Open();
      BigQueryDataReader bigQueryReader = bigQueryCommand.ExecuteReader();
      try
      {
        while (bigQueryReader.Read())
        {
          Console.WriteLine(bigQueryReader.GetInt64(0) + ", " + bigQueryReader.GetString(1));
        }
      }
      finally
      {
      // always call Close when done reading.
      bigQueryReader.Close();
      // always call Close when done reading.
      bigQueryConnection.Close();
      }
    }
    Public Sub ReadMyData(myConnString As String)
      Dim mySelectQuery As String = "SELECT id, first_name FROM your_project.your_dataset.employees"
      Dim bigQueryConnection As New BigQueryConnection(myConnString)
      Dim bigQueryCommand As New BigQueryCommand(mySelectQuery, bigQueryConnection)
      bigQueryConnection.Open()
      Dim bigQueryReader As BigQueryDataReader = bigQueryCommand.ExecuteReader()
      Try
        While bigQueryReader.Read()
          Console.WriteLine(bigQueryReader.GetInt64(0) + ", " _
            + bigQueryReader.GetString(1))
        End While
      Finally
          ' always call Close when done reading.
          bigQueryReader.Close()
          ' always call Close when done with connection.
          bigQueryConnection.Close()
      End Try
    End Sub
    Inheritance Hierarchy

    System.Object
       System.MarshalByRefObject
          System.ComponentModel.Component
             System.Data.Common.DbCommand
                Devart.Common.DbCommandBase
                      Devart.Data.BigQuery.BigQueryCommand

    See Also