StrataFrame Forum

Error in business object...

http://forum.strataframe.net/Topic950.aspx

By StarkMike - 4/26/2006

I'm getting an error in my business object when I try to run my app. I can understand what the debugger is telling me is wrong, but what I'm not sure of is how to fix it. The problem is I have a date field that contans nulls... that is the field will only contain a date when it is applicable. Most other times it will be empty. I'm including a screenshot of the error.



Thanks
By Trent L. Taylor - 4/26/2006

Mike,

You need to return some type of alternate value when you have a field that will support NULL values, this way you can avoid this error.  You can use a nullable generic or just returned a specified value when the value is DBNull.  To do this you will need to do the following:

  1. Open up the BO Mapper and navigate to your business object.  
  2. Select the DeferredTo field and click "Customize."  This will bring up the Custom Field Properties.  
  3. Under NULL Value Support, select "Use Nullable Generic" and then click OK.  
  4. Rebuild your partial class by using the Context Menu on the one BO that you just modified or click the "Rebuild All" button.  
  5. Run your application and the error should be gone.

You could also return an alternate value by selecting the "Return Alternate On Null" and then setting the "Null Replacement" value to #01/01/1800#

FYI:  All StrataFrame controls will respect #01/01/1800# as a NULL value so you can clear out the contents of a DateTime field by setting the ClearOnNull property.  If you do not want to use 01/01/1800 as the null date, you can set it to whatever you like and then set the NullDateValue property on the DateTimePicker to the date you prefer to use a "null".

Hope this helps. Smile

By StarkMike - 4/26/2006

Trent, thanks for the response. I figured this one out by myself but since I am new to StrataFrame I wanted an "Official" answer. Wink I ended up choosing "Use Nullable Generic" and it seems to work fine for now.
By Trent L. Taylor - 4/26/2006

I'm glad that you found the answer.  But I understand that sometimes it's nice to have confirmation as well BigGrin