SnowflakeDataReader Class
Reads a forward-only stream of rows from Snowflake.
The following example creates a
SnowflakeConnection, a
SnowflakeCommand, and a
SnowflakeDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the
SnowflakeDataReader, then the
SnowflakeConnection.
|
|---|
public void ReadMyData(string myConnString) {
SnowflakeConnection snowflakeConnection = new SnowflakeConnection(myConnString);
SnowflakeCommand snowflakeCommand = (SnowflakeCommand)snowflakeConnection.CreateCommand();
snowflakeCommand.CommandText = "SELECT id, first_name, last_name FROM your_database.your_schema.employees";
snowflakeConnection.Open();
SnowflakeDataReader snowflakeReader = snowflakeCommand.ExecuteReader();
try {
// Always call Read before accessing data.
while (snowflakeReader.Read()) {
Console.WriteLine(snowflakeReader.GetInt64(0) + " " +
snowflakeReader.GetString(1) + " " + snowflakeReader.GetString(2));
}
}
finally {
// always call Close when done reading.
snowflakeReader.Close();
// Close the connection when done with it.
snowflakeConnection.Close();
}
} |
|
|---|
Public Sub ReadMyData(ByVal myConnString As String)
Dim snowflakeConnection As New SnowflakeConnection(myConnString)
Dim snowflakeCommand As SnowflakeCommand = snowflakeConnection.CreateCommand()
snowflakeCommand.CommandText = "SELECT id, first_name, last_name FROM your_database.your_schema.employees"
snowflakeConnection.Open()
Dim snowflakeReader As SnowflakeDataReader = snowflakeCommand.ExecuteReader()
Try
' Always call Read before accessing data.
While snowflakeReader.Read()
Console.WriteLine(String.Concat(snowflakeReader.GetInt64(0), " ", _
snowflakeReader.GetString(1), " ", snowflakeReader.GetString(2)))
End While
Finally
' always call Close when done reading.
snowflakeReader.Close()
' Close the connection when done with it.
snowflakeConnection.Close()
End Try
End Sub |