Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Assigning a DefaultValue for a sql server uniqueidentifier datatype: NewGuid

One of our Datatables pk is a uniqueidentifier.  I could not figure out how to set the DefaultValue for this DataColumn. 

Easy enough:

col.DefaultValue = System.Guid.NewGuid

NewGuid will generate a new guid for you.  I was using NEWID on the sql side.  I can get rid of this now and set the DefaultValue.  2 birds killed with one stone.

3 Comments

Comments have been disabled for this content.