Represents a SQL statement or stored procedure to execute against Google BigQuery.
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 |