Working with UniqueIdentifiier when inserting from App.
Hi.
I have a table with id(pk),name,surname and email. I want to add a record using the SQLClient. When I set up the SQLCommand and specifying the values to insert, do I need to specify all four colum values or will it be possible to only specify name, surname and email because of the UniqueIdentifier? What I am trying to do here is add records to the table with my code but ensuring that the ID is always incremented with 1 when I add a new entry. How can I achieve this?
Karthikeyan SPosted Apr 13, 2009, 11:46 AM
To ensure primary key value is incremented by one, you have to set the properties 'Is Identity' as 'Yes' and Identity Increment as 1 and Identity Seed as 1.
Then to insert the values, you can not insert all the four values. Because the first value is auto-increment, we have to give the rest 3 values.
Ex: INSERT INTO TABLE_NAME VALUES('FIRST NAME', 'LAST NAME', '[email protected]')