Problems with NULL


Author
Message
Howard Bennett
Howard Bennett
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 57, Visits: 496
I'm using DDT to setup a new database.  When I started I uncheked "Allow Null default value."  Don't know why - just thought that's what I was supposed to do...

I was able to setup my table and put fields on a form - no problems. 

I decided to add a couple of fields and the deployment to the server fails - b/c "Allow Null" is not checked (like the other fields.)  If I check the field - the deployment works - but the app fails with a "Conversion from type 'DBNull' to type 'String' is not valid."

Just need someone to tell me where I messed up and how to fix it - thanks!

HB

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Howard!

At the time you were adding new fields into your table at the DDT, have you tried assigning "Default Values" on the Additional Settings group?

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Ivan's got it right. If you have existing data in the database and you need to add a field that does not allow NULLs, then you have two options (these are SQL Server restraints, not DDT restraints...or rather, the DDT just has to live with the SQL server restraints):



- You add the field and set it to not allow NULLs and you must set a default.

- You add the field and allow NULLs, then after the field is added, you go in and populate the new field with data, then go back and change the field to not allow NULLs.



The first is almost always the way to go unless there is something complicated going on with the field.



Note that if you need to change a field that was formally NULL to one that is NOT NULL (SQL terminology here), then the same issue applies with the same possibilities.



Hope that helps!
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
Wow...you guys are getting good BigGrin  Ivan and Greg are right.  Property standards really lean away from default value support, you are better off assigning a default value.  The reason this worked initially is because you did not have any records.  But now that you have records in the table, you just need to assign a default value so that the existing records will initialize their fields with a value rather than DBNULL.
Howard Bennett
Howard Bennett
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 57, Visits: 496
Okay - that did the trick - thanks!
Howard Bennett
Howard Bennett
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 57, Visits: 496
I played around with that - but apparently not the right combination of allow nulls and default values.  It's working now with a default value and "Allow Nulls" not checked. Thanks for your help!
Howard Bennett
Howard Bennett
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 57, Visits: 496
So...let me be sure I've got this straight...

When I setup the table - I am correct in unchecking the "Allow Nulls" checkbox - and when adding fields, I need to be sure there is a default value and the "Allow Nulls" is not checked.  Is that right?

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
Correct.  You really don't want to allow null values within a database if you have control over it.  When you initially create your structures, you can leave the Default blank and not select Allow Nulls and deploy without any type of error as you are deploying a new structure where there are no records...thus no field values have to be initialized.  But when you go back into that structure and add new columns to an already deployed table, you will want to be sure to supply a default value, otherwise you will run into the issue that you experienced.  But it is best to not allow nulls. Smile
Howard Bennett
Howard Bennett
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 57, Visits: 496
Thanks for the help...again...
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
No problem Smile
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