dotConnect for Google BigQuery Documentation
Devart.Data Namespace / SqlShimDataReader Class / Read Method
Example

On this page
    Read Method (SqlShimDataReader)
    On this page
    Advances the SqlShimDataReader to the next record.
    Syntax
    'Declaration
     
    Public Overrides Function Read() As Boolean
    public override bool Read()

    Return Value

    true if there are more rows; otherwise, false.
    Remarks
    The default position of the SqlShimDataReader is prior to the first record. Therefore, you must call Read to begin accessing any data.

    While the SqlShimDataReader is in use, the associated Devart.Data.BigQuery.BigQueryConnection is busy serving it until you call Close.

    Example
    The following example creates a Devart.Data.BigQuery.BigQueryConnection, a Devart.Data.BigQuery.BigQueryCommand, and a SqlShimDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the SqlShimDataReader, then the Devart.Data.BigQuery.BigQueryConnection.
    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;
      bigQueryReader = bigQueryCommand.ExecuteReader();
      // Always call Read before accessing data.
      while (bigQueryReader.Read()) {
        Console.WriteLine(bigQueryReader.GetString(0) + ", " + bigQueryReader.GetString(1));
      }
      // always call Close when done reading.
      bigQueryReader.Close();
      // Close the connection when done with it.
      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
      bigQueryReader = bigQueryCommand.ExecuteReader()
      ' Always call Read before accessing data.
      While bigQueryReader.Read()
        Console.WriteLine(bigQueryReader.GetString(0) + ", " _
          + bigQueryReader.GetString(1))
      End While
      ' always call Close when done reading.
      bigQueryReader.Close()
      ' Close the connection when done with it.
      bigQueryConnection.Close()
    End Sub
    See Also