Add GUIDs to new GUID column
I recently added a GUID column to an employee table. How can I programmatically add GUIDs to these columns?
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
Kirtan PatelRank #292 · 8.6K reputationPosted Nov 18, 2009, 6:35 AM EST
Here is Coding How to Do it
please check "Do you like this answer checkbox if it helps you" :)
Guid x = Guid.NewGuid();
SqlConnection con = new SqlConnection("Your Connection String ");
con.Open();
SqlCommand comm = new SqlCommand("insert into TableName(YourGUIDColumn) values(@guidValue)",con);
comm.Parameters.AddWithValue("@guidValue", x);
comm.ExecuteNonQuery();
con.Close();
patrickRank #4,458 · 342 reputationPosted Nov 18, 2009, 8:50 AM EST
Sam HobbsRank #107 · 20.5K reputationPosted Nov 18, 2009, 12:26 PM EST
Kirtan PatelRank #292 · 8.6K reputationPosted Nov 18, 2009, 2:43 PM EST
then Set Column Property Like below in Database so that 20 employee will have new ID Automatically
check "Do you like this answer check box" if my answer helps you :)