Hello Friends. I need to save information that is in a DateTimePicker control (in a form of the type of maintenance) with the null value in database and a way to solve this was to include the following code in the Save method Before Bo:
'Field1
If parmfisc_data_vigencia_final.Text.ToString () = "1/1/1800" Or parmfisc_data_vigencia_final.Text.ToString () = "" Then
boParametros_Fiscais1.CurrentRow (parmfisc_data_vigencia_final ") = DBNull.Value
Else
boParametros_Fiscais1.CurrentRow (parmfisc_data_vigencia_final ") = parmfisc_data_vigencia_final.Text.ToString ()
End If
'Field2
If parmfisc_data_vigencia_inicial.Text.ToString () = "1/1/1800" Or parmfisc_data_vigencia_inicial.Text.ToString () = "" Then
boParametros_Fiscais1.CurrentRow (parmfisc_data_vigencia_inicial ") = DBNull.Value
Else
boParametros_Fiscais1.CurrentRow (parmfisc_data_vigencia_inicial ") = parmfisc_data_vigencia_inicial.Text.ToString ()
End If
But I have two problems
1 - When you click Save: When I start the application the first time I click to insert a new record, fill in the registration and click on save, I get the following exception:
BusinessLayerException
An error occurred while saving an the data to the server.
ArgumentOutOfRangeException
Value of '01 / 01/0001 00:00:00 'is not valid for' Value '. 'Value' Should Be between 'MinDate' and 'MAXDATA'.
Parameter name: Value
But if I click on save again, the record is saved and then usually have no more exceptions. during the execution of this module.
2 - When loading a register via a Browse Dialog: search a record in the Browse dialog that has a date as Null and select it I get the following exception:
BusinessLayerException
An error occurred while refreshing the data from field 'boParametros_Fiscais.parmfisc_data_vigencia_final' to property 'BindableValue' on control 'parmfisc_data_vigencia_final. " Are you missing FieldPropertyDescriptor for a custom property?
ArgumentOutOfRangeException
Value of '01 / 01/0001 00:00:00 'is not valid for' Value '. 'Value' Should Be between 'MinDate' and 'MAXDATA'.
Parameter name: Value
But if I make a filter with a set of records that have dates or not to null I can browse normally and click edit on a record that has null as date, make any changes and click save've no exception .
What I see is an unstable behavior, because not always an exception. Is there a way to solve this problem?
I apologize for English via Google Translator and thank you in advance!