问题
retreiving last inserted id
I want to retreive last inserted id from firebird database. Data is succ. inserted, trigger inserts id as it should using generator.
I'm advised to use this syntax
var sql = "INSERT INTO ... VALUES ... " +
"RETURNING Id";
where RETURNING
Id should return table Id.
I dont know how to store into variable.
int lastId = ...
回答1:
var con = OpenFB2Connection();
var trans = con.BeginTransaction();
var command = new OleDbCommand("INSERT INTO ... VALUES ... RETURNING Id");
cmd.Parameters.Add("Id", OleDbType.Integer).Direction = ParameterDirection.Output;
var Id = (int)cmd.ExecuteScalar(); //Here is your Id
来源:https://stackoverflow.com/questions/20271814/retrieve-last-id-from-firebird-db-table