daelmo wrote:
It's better to work with triggers in this case. You can use a trigger (before insert) and set the sequence name for the column to @@IDENTITY.
Thank you for your answer, but I am not sure if I understand what you mean.
Are you talking about a database trigger on the table to which I want to insert a new record, let's call it T_SomeTable? Wouldn't this mean that other applications which use the old meachnism of first calculating and retrieving the next primary key value from the special tables T_Sequence and second use this key as a primary key in the new record, are also influenced by this mechanism? And which @@IDENTITY value should I use, because the tables in our database do not have identity fields?
In my opinion any solution should increment the sequence value in the T_Sequence table, retrieve it and use it as a primary key for the inserted record in T_SomeTable. Preferably during 1 database call, hence my suggestion of using a stored procedure.
Ofcourse I can also retrieve the new primary key with a separate stored procedure call, and then set the class property, but since I am building a client-server application, in that case I would like to do this on the server side. I guess this means the database specific part?
Ron