StrataFrame Forum

Issue with a PK...

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

By Greg McGuffey - 6/18/2008

I had a BO that I was setting the PK for manually, then realized I actually wanted it to be an auto-increment PK. I updated the db, rebuilt the BO, got rid of my SetDefaultValues code, and changed the PrimaryKeyIsAutoincremented and PrimaryKeyIsUpdatable to True and False respectively.



Now, whenever I try to navigate to a new row, I get a type conversion error from dbnull to integer. I must be missing something. Any ideas?
By Edhy Rijo - 6/18/2008

Hi Greg,

It looks like you are getting DBNull data for that PK value, try setting the Null Value Option in the BOM to Return Alternate on Null with zero or empty string based on your field type.

By Greg McGuffey - 6/18/2008

Well, that's just it. It is an auto incremented PK. It shouldn't allow NULLs. What it is acting like is that the PrimaryKeyIsAutoIncremented property is still set to False.



I checked the SF source and I see no way for a new row with a PK set that is auto incrementing to skip the initialization to -1, -2 etc. The only way is if the PrimaryKeyIsAutoIncremented is False or if there isn't a PK set on the BO (that I see). I checked the properties on the BO (they're OK), I checked the designer file itself (it's OK...PK is set, PrimaryKeyIsAutoIncremented is not set (so defaults to True)). I'm baffled....oh...wait



[runs to dev computer (er...hits scrolllock scrolllock 2 to get to dev computer on KVM)...opens form where problem is occurring...looks at properties of BO instance...DOH...slams head on desk...looks at pretty stars]



Blush



The PrimaryKeyIsAutoIncremented and PrimaryKeyIsUpdatable were set on the instance. All is working now.... Satisfied
By Edhy Rijo - 6/18/2008

Greg McGuffey (06/18/2008)
The PrimaryKeyIsAutoIncremented and PrimaryKeyIsUpdatable were set on the instance. All is working now.... Satisfied


Glad to hear you found it.  This type of things usually takes more than a couple of hours to find and most of the time it is under our nose Smile.

By Bill Cunnien - 6/19/2008

...looks at properties of BO instance...DOH...slams head on desk...looks at pretty stars

I am sooooo glad that this happens to other programmers, too.  Despite our best efforts to prove otherwise, we are all still quite human.

I feel your pain,
Bill

BigGrin

By Trent L. Taylor - 6/19/2008

Hope you didn't hurt your head too much when you slammed in on the desk BigGrin Me...I have huge mountain sized knots protruding from my head pretty much all of the time Crazy
By Greg McGuffey - 6/19/2008

Just put some RICE* it. Tongue





*RICE=Rest Ice Compression Elevation...never to be done on ones head Hehe
By Trent L. Taylor - 6/19/2008

LOL...good advice Smile