ExecuteReader(CommandBehavior) Method
The following example creates a
SnowflakeCommand, then executes it by passing a string that is SQL SELECT statement, and a string to use to connect to the data source. The
System.Data.CommandBehavior is then set to CloseConnection.
|
|---|
public void CreateSnowflakeDataReader(string mySelectQuery,string snowflakeConnectionString)
{
SnowflakeConnection snowflakeConnection = new SnowflakeConnection(snowflakeConnectionString);
SnowflakeCommand snowflakeCommand = new SnowflakeCommand(mySelectQuery, snowflakeConnection);
snowflakeCommand.Connection.Open();
SnowflakeDataReader snowflakeReader = snowflakeCommand.ExecuteReader(CommandBehavior.CloseConnection);
while(snowflakeReader.Read())
{
Console.WriteLine(snowflakeReader.GetString(0));
}
snowflakeReader.Close();
} |
|
|---|
Public Sub CreateSnowflakeDataReader(mySelectQuery As String, _
snowflakeConnectionString As String)
Dim snowflakeConnection As New SnowflakeConnection(snowflakeConnectionString)
Dim snowflakeCommand As New SnowflakeCommand(mySelectQuery, snowflakeConnection)
snowflakeCommand.Connection.Open()
Dim snowflakeReader As SnowflakeDataReader = snowflakeCommand.ExecuteReader(CommandBehavior.CloseConnection)
While snowflakeReader.Read()
Console.WriteLine(snowflakeReader.GetString(0))
End While
snowflakeReader.Close()
End Sub |