StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



About null values with ReturnAlternateOnNull...Expand / Collapse
Author
Message
Posted 05/31/2006 1:30:26 PM
StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: Forum Members
Last Login: 01/10/2008 9:33:30 AM
Posts: 65, Visits: 820
Hi,

In my BusinessObjects there are two fields that initially will be null. The fields are CREATED (DATE) and CREATED_BY (Char). In the Business Object Mapper these have been set to "Return Alternate On Null". The CREATED has the NULL replacement set to System.DateTime.Today. CREATED_BY has the same value set to String.Empty.

When compiling the application the following error is returned:

For the CREATED field the error message is

Error 1 Class 'Field_CREATED_Descriptor' must either be declared 'MustInherit' or override the following inherited 'MustOverride' member(s):
    System.ComponentModel.PropertyDescriptor : Public MustOverride Sub SetValue(component As Object, value As Object). File: BO_CompanyDetails.Designer.vb

and for the CREATED_BY the error is

Error 2 Class 'Field_CREATED_BY_Descriptor' must either be declared 'MustInherit' or override the following inherited 'MustOverride' member(s):
    System.ComponentModel.PropertyDescriptor : Public MustOverride Sub SetValue(component As Object, value As Object). FILE: BO_CompanyDetails.Designer.vb 

Any ideas how to fix this?

TIA,
Kari

ps. Is it possible to have the  CREATED -field to be null rather than the  System.DateTime.Today (The dartabase would take care of setting the value in case it's null)

Post #1306
Posted 05/31/2006 1:40:49 PM
StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: Forum Members
Last Login: 01/10/2008 9:33:30 AM
Posts: 65, Visits: 820
Hi,

I resolved(?) this. The conflict was caused by the fact that I had also checked the "Read Only" check box for the fields in questiion. Clearing that removed the error.

Sorry for the "red herring"

Kari

Post #1307
Posted 05/31/2006 1:58:56 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 08/01/2008 8:53:41 AM
Posts: 2,671, Visits: 1,879
No, Kari, that's actually a bug... the SetValue method still needs to be overridden, even if the property is specified as ReadOnly. 

ps. Is it possible to have the  CREATED -field to be null rather than the  System.DateTime.Today (The dartabase would take care of setting the value in case it's null)

Yes, Kari, you can.  Basically, when you create a new record within the business object, the business object will initialize the fields within the new row so that there are no NULL values.  If you want all of the fields to be null, then you can set the AllowNullValues property on the business object to True, and the BO will not initialize the values (leaving the NULLs).  But, if you just want NULL values on those 2 fields, then your best bet is to do this:

Within the SetDefaultValues() event handler of the business object, put these 2 lines:

Me.CurrentRow.Item("Created") = DbNull.Value

Me.CurrentRow.Item("Created_By") = DbNull.Value

This will initialize those 2 fields with null values.  Your properties will still return the alternate values, but those null values will be saved back to the database.


www.bungie.net
Post #1308
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 7:53pm

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.109. 8 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.