Code
InsertCommand="INSERT INTO [TableOne] ([PersonID], [Name], [Image]) VALUES (@PersonID, @Name, @Image)
Performing this work, PersonID (Primary Key) 's wants. But I want to program make a Primary Key. What should I do?
Thank you.InsertCommand="INSERT INTO [TableOne] ([PersonID], [Name], [Image]) VALUES (@PersonID, @Name, @Image)
Performing this work, PersonID (Primary Key) 's wants. But I want to program make a Primary Key. What should I do?
Thank you.Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Micke BlomqvistRank #1,660 · 923 reputationPosted Feb 6, 2011, 8:48 AM EST
I don't know what db you use, but most of the allows you to add a identity column on a table, where you can set the startvalue and the seed(increment), and where the db it self keeps record of and giving each record a uniqe value. (int)
If you already have data in your table, you need save it to another one, and then add a identity column. Then you just re-insert the records using the SQL statement:
insert table_with_identity_column_table select PersonID, Name, Image from copy_table. You can use the above statement to insert new records, you don't supply any value for the identity column.
Each and every row get their uinqe identity and you can easilly return the output parameter @@Identity to get what the actual value back to you application.
Suthish NairRank #92 · 22.8K reputationPosted Feb 7, 2011, 12:43 AM EST
Please explain the thread with more information, so we can help you.