String Comparison in BO is not working properly


Author
Message
Jeff Pagley
Jeff Pagley
StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)
Group: StrataFrame Users
Posts: 223, Visits: 893
I have setup a field string value in the BO Mapper custom field properties as follows:

Return Alternate on Null/Set Null on Alternate (reference type)

NULL Replacement Value: ""

The problem is when I clear the field value on the form's control and save, the BO is writing an empty string back to the database instead of NULL.

However, when I modify your BO code by changing [If value IsNot "" Then] to

[If value.Length > 0 Then] (see modified code below),  the logic works and the BO writes the NULL value back to the database.

What is going on here?

''' <summary>

''' JobAddress

''' </summary>

''' <remarks></remarks>

<Browsable(False), _

BusinessFieldDisplayInEditor(), _

Description("JobAddress"), _

DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _

Public Property [JobAddress]() As System.String

Get

Dim loValue As Object

loValue = Me.CurrentRow.Item("JobAddress")

If loValue Is DBNull.Value Then

Return ""

Else

Return CType(loValue, System.String)

End If

End Get

Set(ByVal value As System.String)

' If value IsNot "" Then

If value.Length > 0 Then

Me.CurrentRow.Item("JobAddress") = value

Else

Me.CurrentRow.Item("JobAddress") = DBNull.Value

End If

End Set

End Property


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