Null Value + DateTime Picker = Exception (but not always)


Author
Message
Eduardo
Eduardo
StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)
Group: Forum Members
Posts: 12, Visits: 80
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!

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Eduardo,

I think you can solve your problem by doing the following: In the Business Object Mapper, set the following options for you business object:

NULL Value Option: Return Alternate on Null

NULL Replacement Value: #1/1/1800#



Build Partial, compile your project and test.

Edhy Rijo

Eduardo
Eduardo
StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)
Group: Forum Members
Posts: 12, Visits: 80
Edhy Hello, how are you?

It may seem strange, but I do not have access to the BO, and I'm only working on the application level.
I have owned my DateTimePicker value configured for this alternative.
I do not know if there is a way to solve this without changing the BO.

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Eduardo (07/29/2010)
Edhy Hello, how are you?



It may seem strange, but I do not have access to the BO, and I'm only working on the application level.

I have owned my DateTimePicker value configured for this alternative.

I do not know if there is a way to solve this without changing the BO.




Well, that should be the proper way to fix this at the BO level, if you don't have access to the BO to make the changes then you will have to do some coding at the form level where this BO will be used.

Edhy Rijo

Eduardo
Eduardo
StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)
Group: Forum Members
Posts: 12, Visits: 80
One solution to the problem was
set the field as BO.field = Nothing
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search