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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kirtan PatelPosted Nov 18, 2009, 7:43 PM
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 :)
Sam HobbsPosted Nov 18, 2009, 5:26 PM
patrickPosted Nov 18, 2009, 1:50 PM
Kirtan PatelPosted Nov 18, 2009, 11:35 AM
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();