Sunday, February 19, 2012

Allowing null dates

My users want to be able to enter nothing in a date field.

I'm using asp.net v2, vb.net, and VS 2005 for my application. I'm not sure what to do or what code to write to allow the user not to enter a date and keep from hitting the sqldatetime overflow error.

I could use some help.

Thanks

If the application variable/control value for the datatime value is empty (EmptyString), your application should set the input parameter to SqlType.dbNull -NOT the input control.text value.

|||

Thank you.

I figured out I needed to write that code in my business logic layer. I know this is an issue with a lot of people. Here is how I solved my problem.

I set the variable to Nullable (of DateTime)

And made the following check

If Not fldIntake.HasValue Then ClientApp.SetfldIntakeNull() Else ClientApp.fldIntake = fldIntake.Value

No comments:

Post a Comment