|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Default DateTime Value in a columnHi,
Im creating an in memory DataTable. I have a "dtCreated" column that I want to be populated with the current date and time when a record is added. I dont want to code this every time I add a record. Is there a way to set the defaultValue of the column so that is always inserts the current date time when a record is added. I want this to work like a SQL Server column that has "getdate()" as the default value. Thanks in advance... Perhaps you might consider implementing DataTable.RowChanged event and
initialize default values there. -- Show quoteMiha Markic [MVP C#] RightHand .NET consulting & development www.rthand.com Blog: http://cs.rthand.com/blogs/blog_with_righthand/ "Josh" <s@a.com> wrote in message news:%23u0lh2cIGHA.524@TK2MSFTNGP09.phx.gbl... > Hi, > > Im creating an in memory DataTable. I have a "dtCreated" column that I > want to be populated with the current date and time when a record is > added. I dont want to code this every time I add a record. > > Is there a way to set the defaultValue of the column so that is always > inserts the current date time when a record is added. > > I want this to work like a SQL Server column that has "getdate()" as the > default value. > > Thanks in advance... > Josh,
You mean something as mycolumn.defaultvalue = Now Not tested and as it works, than it gives for sure the datetime at construction time. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclassdefaultvaluetopic.asp I hope this helps, Cor |
|||||||||||||||||||||||