|
Here is the scenario: A windows form has a calendar control. The user needs to have to option to either set a date in the control, or leave it blank. If the user leaves it blank, a null value needs to be saved to the database. Also, the control needs to display either a blank field or '(none)'.
The Calendar control is bound to an object that inherits from Collection Class and Implements IBindingList. The data is saved to a SQL Server 2000 database via a call to a stored procedure. (We use the ApplicationBlock for Data Access from MS for out client-side data access layer.)
Currently, the datatype in the object is a Date. It is exposed through a read/write property. ie: Private mDate as Date public property MyDate as Date //code to get and set end property
Question: When I try to save the date value as a null, I get a SQL Server exception. I have tried making the mDate variable a SQLTypes.SqlDate value, but this did not work.
Any suggestions on how I can accomplish this would be greatly appreciated. I know I can perform a type swap at the Property, but would prefer a more elegant solution, if one exists.
Thanks. |