Hi
My VB.NET application fills it's dataset out of a SQL Server database. I know that the Default Values from the database do not copy across to the dataset so I have started looking for other ways to do this.
I have found that the default values are stored in the SQL Server System Tables, and can be retrieved using....
Which works perfectly for most datatypes. DateTime however are not so good.
Heres where my questions come in.
1) How do you guys/girls handle getting the default dates from your databases??
It must be a common problem, and I wouldn't like to have to hard code them in incase the business logic changes, granted, thats not going to happen often, but I want to do things as correctly as I can. So any advise on how you all handle your default values would be greatly appreciated.
2) How do you set a DateTime datacolumn's default value to the exact time the new row is created??
I would have thought:
But when I do this on application start and then change my computer time to tomorrow, then create a new row, the new row has today's date.
Is my test flawed??? or does setting the column's default value to Now() make the default value the actual date value of Now ie (7/29/2004 13:20:00)??
Thank you in advance for any help you can offer.
Hope you're all having a good week!
Cheers
Nells
My VB.NET application fills it's dataset out of a SQL Server database. I know that the Default Values from the database do not copy across to the dataset so I have started looking for other ways to do this.
I have found that the default values are stored in the SQL Server System Tables, and can be retrieved using....
Code:
SELECT
dbo.sysobjects.name, dbo.syscomments.text
FROM
dbo.sysobjects
INNER JOIN
dbo.syscomments
ON dbo.sysobjects.id = dbo.syscomments.id
WHERE
(dbo.sysobjects.xtype = 'D')
ORDER BY
dbo.sysobjects.name
Which works perfectly for most datatypes. DateTime however are not so good.
Heres where my questions come in.
1) How do you guys/girls handle getting the default dates from your databases??
It must be a common problem, and I wouldn't like to have to hard code them in incase the business logic changes, granted, thats not going to happen often, but I want to do things as correctly as I can. So any advise on how you all handle your default values would be greatly appreciated.
2) How do you set a DateTime datacolumn's default value to the exact time the new row is created??
I would have thought:
Code:
datacolumn.DefaultValue = Now()
Is my test flawed??? or does setting the column's default value to Now() make the default value the actual date value of Now ie (7/29/2004 13:20:00)??
Thank you in advance for any help you can offer.
Hope you're all having a good week!
Cheers
Nells