title: PostgreSQL Parameterized Insert with ADO.NET
body: <p>I am using NpgSQL with PostgreSQL and ADO.NET.  Forgive the simplicity of the question as I just started using PostgreSQL and NpgSQL this week.</p>
  
  <p>Something like this works fine:</p>
  
  <pre><code>[Test]
  public void InsertNoParameters()
  {
      NpgsqlConnection conn = new NpgsqlConnection("Host=localhost; Database=postgres; User ID=postgres; Password=password");
      conn.Open();
  
      IDbCommand command = conn.CreateCommand();
      string sql = "INSERT INTO Customers (FirstName,LastName) VALUES ('Test','Tube')";
      command.CommandText = sql;
      command.ExecuteNonQuery();
      conn.Close();
  }
  </code></pre>
  
  <p>When I put in parameters I get the error message:
  Npgsql.NpgsqlException : ERROR: 42703: column "_firstname" does not exist</p>
  
  <pre><code>[Test]
  public void InsertWithParameters()
  {
  NpgsqlConnection conn = new NpgsqlConnection("Host=localhost; Database=postgres; User ID=postgres; Password=password");
  conn.Open();
  
  IDbCommand command = conn.CreateCommand();
  string sql = "INSERT INTO Customers (FirstName,LastName) VALUES (_FirstName,_LastName)";
  command.CommandText = sql;
  
  var parameter = command.CreateParameter();
  parameter.ParameterName = "_FirstName";
  parameter.Value = "Test";
  command.Parameters.Add(parameter);
  
  parameter = command.CreateParameter();
  parameter.ParameterName = "_LastName";
  parameter.Value = "Tube";
  command.Parameters.Add(parameter);
  
  command.ExecuteNonQuery();
  conn.Close();
  }
  </code></pre>