I noticed using the PostgreSQLDirect.NET provider that PgSQLCommand doesn't contain a property "InsertID" which is present in the MySQLCommand equivalent. There is a property called "InsertOid" but that's not the same thing.
So, supposing I create a table "animal" with two columns:
Code: Select all
CREATE TABLE animal (
id serial NOT NULL,
description varchar(80)
);
Code: Select all
///
/// this method should insert a new chicken into the database and
/// return the new chicken's auto-incremented id value.
///
private int insertAnotherChicken() {
// the command to be used for chicken insertion
PgSqlCommand InsertCommand = new PgSqlCommand();
...
InsertCommand.CommandText = "INSERT INTO animal(description) VALUES ('Chicken')";
...
InsertCommand.ExecuteNonQuery();
// HELP!!!!
// how do I return the id of the newly inserted chicken
return ???;
}
Thanks in advance for your help...
Cheers,
DaveW.