Using Delphi 5, I am trying to make an application that uses an ODBC connection to a MS SQL Server DB which contains three tables. After reading about the flaws of using auto-increment primary keys, I am trying to increment the key within the application, but when I try to post to the database I always get a "cannot insert duplicate values into primary key." even though it is a new entry into the DB with no value in the key field.
What I am doing is querying the key field with "SELECT max(pkGuestID) FROM Guest" to get the highest value in the DB, then I write that to a variable and add one to it then try to write it back to the db with the new record. Is this the right thinking? Is there a better way to do this?
Thanks, Faded
What I am doing is querying the key field with "SELECT max(pkGuestID) FROM Guest" to get the highest value in the DB, then I write that to a variable and add one to it then try to write it back to the db with the new record. Is this the right thinking? Is there a better way to do this?
Thanks, Faded