W
wapsiii
I'm unsure how best to handle dates from my webforms to my database.
Often I have a textbox and a datepicker on a webform. Upon postback
dates are received in string format (like DD-MM-YYYY). Ultimately the
dates need to be stored in a datetime/smalldatetime field in the sql
server. However, first I pass then dates to the db via a business
layer where the date properties are of type datetime.
I've explored several ways to handle this scenario, but am unsure
which of the ways are the "best".
Should I first:
1) enter the posted textbox.text into a string variable,
2) try catch type cast the string variable into a datetime variable
(if the type cast fails should I set the datetime property of the
business layer to null/nothing? / or how should optional dates be
handled).
Morten
Often I have a textbox and a datepicker on a webform. Upon postback
dates are received in string format (like DD-MM-YYYY). Ultimately the
dates need to be stored in a datetime/smalldatetime field in the sql
server. However, first I pass then dates to the db via a business
layer where the date properties are of type datetime.
I've explored several ways to handle this scenario, but am unsure
which of the ways are the "best".
Should I first:
1) enter the posted textbox.text into a string variable,
2) try catch type cast the string variable into a datetime variable
(if the type cast fails should I set the datetime property of the
business layer to null/nothing? / or how should optional dates be
handled).
Morten