Groups | Blog | Home
all groups > dotnet ado.net > june 2007 >

dotnet ado.net : How to auto add record creation date/time


VB Programmer
6/29/2007 5:12:34 PM
In my ASPNETDB.MDF database I have a custom table, with a field called
"InsertionDate", which tells the user when the record was created. How do I
auto-populate this field whenever a record is created? Is this field
necessary for this type of info? Thanks

Nathan Sokalski
6/29/2007 10:19:12 PM
If you are creating the record using .NET, just get the system date using
either

Date.Now
or
Date.Today

and convert them to the appropriate format for a date in whatever database
you are using. I think this would be the easiest way, since you will
obviously be inserting other fields as part of the record as well. Good
Luck!
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
[quoted text, click to view]

Milosz Skalecki [MCAD]
6/30/2007 11:36:02 AM
Hi there,

Set default value for this column to GetDate(). Every time a record is
inserted SQL server will automatically set the value to current date (of
course if the value was not provided). Have a look here:
http://technet.microsoft.com/en-us/library/ms345150.aspx
(search for default value for binding)

Regards
--
Milosz


[quoted text, click to view]
VB Programmer
6/30/2007 5:47:15 PM
Thanks everyone!

[quoted text, click to view]

AddThis Social Bookmark Button