Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
android.sm
Starting Member
36 Posts |
Posted - 2011-07-16 : 10:50:44
|
(1) why doesn't my date field auto populate the current system time when creating a new record? i use(getdate()) in sql server (default value or binding column property. the date's datatype is datetime.(2) my website is hosted in US - thus capturing US time. Ex: UK: 2011-07-15 21:05:30.630US: 2011-07-15 13:05:30.630 i need a way to take current time and - 8hours hence it becomes UK time. |
|
jeffw8713
Aged Yak Warrior
819 Posts |
Posted - 2011-07-16 : 11:21:56
|
What is the code you are using to insert the new row? If you are specifying anything for that column, the default value will not be used. |
|
|
android.sm
Starting Member
36 Posts |
Posted - 2011-07-16 : 11:38:22
|
hey,i'm not writing any code for it and not passing in any values. i simply want it to auto populate the column when a record is created. |
|
|
android.sm
Starting Member
36 Posts |
Posted - 2011-07-16 : 14:00:43
|
ok i just noticed that it does create the time /date when i manually insert a new record.my code to create the record is using c# DatabaseLayerDataContext db = new DatabaseLayerDataContext(); try { Comment comments = new Comment(); comments.Title = ddlTitle.SelectedValue; comments.FirstName = txtFirstName.Text; comments.LastName = txtLastName.Text; comments.Message = txtMessage.Text; db.Comments.InsertOnSubmit(comments); db.SubmitChanges(); lblDisplayMessage.Text = "Thank you for your message. We will deal with this as soon as possible."; } catch (Exception err) { lblDisplayMessage.Text = "An error occurred - please try again later. Thank you for your patience."; Console.WriteLine("{0}", err.Message); } |
|
|
android.sm
Starting Member
36 Posts |
Posted - 2011-07-16 : 19:03:41
|
fixed. issue was the code. linq to sql in .net doesn't support auto generated values in db other than identity seed. |
|
|
|
|
|