SnowflakeConnection Class
Represents an open connection to Snowflake.
The following example creates a
SnowflakeCommand and a
SnowflakeConnection. The
SnowflakeConnection is opened and set as the
Connection property. The example then calls
ExecuteNonQuery method, and closes the connection. To accomplish this, the
ExecuteNonQuery is passed a connection string and a query string that is SQL INSERT statement.
|
|---|
public void InsertRow(string snowflakeConnectionString)
{
// If the connection string is empty, use default.
if(snowflakeConnectionString == "")
{
snowflakeConnectionString =
"Domain=myorg-myaccount.snowflakecomputing.com;User=your_user;Password=********;Database=your_database;Schema=your_schema;Warehouse=your_warehouse;License Key=**********";
}
SnowflakeConnection myConn = new SnowflakeConnection(snowflakeConnectionString);
string myInsertQuery = "INSERT INTO your_database.your_schema.employees (first_name, last_name) VALUES ('John', 'Smith')";
SnowflakeCommand snowflakeCommand = new SnowflakeCommand(myInsertQuery);
snowflakeCommand.Connection = myConn;
myConn.Open();
try
{
snowflakeCommand.ExecuteNonQuery();
}
finally
{
myConn.Close();
}
} |
|
|---|
Public Sub InsertRow(snowflakeConnectionString As String)
' If the connection string is empty, use default.
If snowflakeConnectionString = "" Then
snowflakeConnectionString = _
"Domain=myorg-myaccount.snowflakecomputing.com;User=your_user;Password=********;Database=your_database;Schema=your_schema;Warehouse=your_warehouse;License Key=**********"
End If
Dim myConn As New SnowflakeConnection(snowflakeConnectionString)
Dim myInsertQuery As String = "INSERT INTO your_database.your_schema.employees (first_name, last_name) VALUES ('John', 'Smith')"
Dim snowflakeCommand As New SnowflakeCommand(myInsertQuery)
snowflakeCommand.Connection = myConn
myConn.Open()
Try
snowflakeCommand.ExecuteNonQuery()
Finally
myConn.Close()
End Try
End Sub |