No NULLs allowed ..how to set to "0" ?

Posts   
 
    
HcD avatar
HcD
User
Posts: 214
Joined: 12-May-2005
# Posted on: 07-Jun-2005 01:44:01   

Hiya,

i have an entity in the customers DB which has a field of type float and is "NOT ALLOW NULL"

When creating a new entity, settings it's fields values (the values of my float field is 0.0) i cannot save because of the constraint "NOT ALLOW NULL". How can i make it save 0.0 as a value, not as NULL ? If i save it as value 1.0, afterwards i can change it to 0.0. But i want 0.0 from the first time simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 07-Jun-2005 10:06:27   

And you actually set the float's value to 0.0 ? You have to set the value of the field, even if it's 0.0 by default.

Frans Bouma | Lead developer LLBLGen Pro
HcD avatar
HcD
User
Posts: 214
Joined: 12-May-2005
# Posted on: 07-Jun-2005 11:52:14   

Well, it's databound to a textbox ..

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 07-Jun-2005 12:00:29   

HcD wrote:

Well, it's databound to a textbox ..

But are you or aren't you setting the value? By default a NULL in teh db or a new value gets the default value defined in TypeDefaultValues.cs. This means for a float, it's 0.0f.

It's wise to define a default constraint in the DB for the field, in this case. By default the fields in a new entity aren't marked as changed when no value is set for that field.

Frans Bouma | Lead developer LLBLGen Pro
HcD avatar
HcD
User
Posts: 214
Joined: 12-May-2005
# Posted on: 07-Jun-2005 12:17:19   

Indeed, you're right, i didn't set it myself to 0, but the textbox showed "0"

Fixed !

thanx