Handling null value


Author
Message
Chan
Chan
Advanced StrataFrame User (723 reputation)Advanced StrataFrame User (723 reputation)Advanced StrataFrame User (723 reputation)Advanced StrataFrame User (723 reputation)Advanced StrataFrame User (723 reputation)Advanced StrataFrame User (723 reputation)Advanced StrataFrame User (723 reputation)Advanced StrataFrame User (723 reputation)Advanced StrataFrame User (723 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

I have a table with 3 fields



Field Name Type ALlow NULL PK Indentity

---------------------------------------------------------------------

ID int No Yes Yes

Descr varchar(30) No No No

FKID int Yes No No







I set my BO to map to this table, set ID and Descr to Do Not Allow NULL; FKID to Use nullable generic in BO mapper allow null option. When I save new record, I found that FKID is always ZERO instead of NULL if I leave FKID blank (bound in combobox). I figured out that myBO.AllowNullValuesOnNewRow = false.



So, I try to set myBO.AllowNullValuesOnNewRow = true but then I will hit error complaint that system unable to convert DBNull to string for textbox. I was thinking to change "Descr" to use "Return alternate on null" option.



May I know is it the prefered way? Or, any recommendation?



Thank you
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Strings do not support a nullable generic.  You will have to use the "Return Alternate Value" option for a string.  Generally when this is selected for a string, then you want to set the return value as "". 
Alexnaldo C Santos
Alexnaldo C Santos
StrataFrame Beginner (8 reputation)StrataFrame Beginner (8 reputation)StrataFrame Beginner (8 reputation)StrataFrame Beginner (8 reputation)StrataFrame Beginner (8 reputation)StrataFrame Beginner (8 reputation)StrataFrame Beginner (8 reputation)StrataFrame Beginner (8 reputation)StrataFrame Beginner (8 reputation)
Group: Forum Members
Posts: 8, Visits: 58
Hi,

I think that is better change the code generate to, like it :

public string MyField
{
  get {

            return CurrentRow.GetString("myField");
        }

    set

         { CurrentRow["myField"] = value; }

}

The "CurrentRow" class must have GetXXXXX for each type, like GetInt(..), GetDate(...), so you can return values more easy, like "null".

Regards,
Alexnaldo Santos

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
The CurrentRow property is a DataRow object reference, not a wrapper for a DataRow, and the DataRow class does not have GetXXX methods like the DbDataReader class does.  Generating the code in the properties was the most efficient solution.
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