StrataFrame Forum

NULL values

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

By Tim Dol - 8/14/2007

I took at a number of forum posts but I can't seem to solve my issue with Nulls. I don't use nulls a whole lot.

I have a field in my notes table called ContactFK. (Integer,Nullable).  It's a foreign key to my contacts table. The contact is optional on a note.  I set the NULL value option in the BO Mapper to 'Use Nullable Generic'.

When I set my field to nothing I get an error 'Specified Cast is not valid' on the following line of code:

CType(component, CRMEntryBO).ContactFK = CType(Value, Nullable(Of System.Int32))

Is there something wrong with this setup?  I used Nullable generic a while back for a System.Double and it worked fine.

Thanks

TIm

 

By Trent L. Taylor - 8/14/2007

Try setting it to Return Alternate value on NULL and then return a zero without any quotes.  See if this resolves the error in your environment.
By Tim Dol - 8/15/2007

Unfortunatley I got the same result. 'Invalid Cast DBNull to Integer'

What's the best way to handle the following situation. (I can use NULL or Not Null, as long as I get it working). 

I have a note table with a field called NoteContact (Int). It's a FK to my contacts table. I do not have to specify a contact for my note.

I have a combobox on my form bound to my NoteContact field. I populate using the population data source settings. I display the contact name on the dropdown and my value member is the contact PK. I should mention that my combobox type is a dropdown.  I need to be able to clear the value (I guess a zero or NULL value) or enter a contact that currently doesn't exist in the list. (I have logic to automatically create a new contact).

Thanks,

Tim

By Trent L. Taylor - 8/15/2007

Is this field in the table structures you sent me the other day?  If so I will look at this when I look at your table structure.
By Tim Dol - 8/16/2007

The table is not in the database I sent you.