Skip to content

Instantly share code, notes, and snippets.

@NeilRobbins
Created April 16, 2014 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NeilRobbins/10861604 to your computer and use it in GitHub Desktop.
Save NeilRobbins/10861604 to your computer and use it in GitHub Desktop.
Demonstrates an issue with Vertica 6.1.3 where VerticaCommands with parameters cannot contain more than one statement.
public static void M(string[] args)
{
var builder = new VerticaConnectionStringBuilder
{
Host = "54.83.238.208",
Database = "Test",
User = "dbadmin",
Password = "password",
Port = 5433,
Pooling = true,
ConnectionTimeout = 360
};
using (var connection = new VerticaConnection(builder.ConnectionString))
{
using (var command = connection.CreateCommand())
{
// drop schema if exists f;
// create schema f;
// create table f.test(id INT, username VARCHAR, email VARCHAR, password VARCHAR);
command.CommandText = "INSERT INTO j.test VALUES(@ID, 'blah','blah','blah') ; SELECT id FROM j.test LIMIT 1;";
connection.Open();
var param1 = new VerticaParameter("ID", VerticaType.BigInt) {Value = 100};
command.Parameters.Add(param1);
var rowsAdded = command.ExecuteScalar();
Console.WriteLine("Added {0} rows!", rowsAdded);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment