views:

222

answers:

4

I'm setting up an ADO-based client dataset, and when I try to insert a null value into a TIntegerField, on Post I get Project raised exception class EDatabaseError with message 'Non-nullable column cannot be updated to Null'.

I know I've seen a way to set a TField as nullable before, but I can't remember where or how. Does anyone know how to fix this?

EDIT: The field is set to Required = false at design time, and I've verified that it's still false at runtime, but I still get the error.

+1  A: 
MyField.Required := False;
Craig Stuntz
A: 

From help to Delphi 5:

property Required: Boolean;

but be aware of:

property CustomConstraint: String;

Also some implementation of classes inherited from TDataSet may add some logic on their own...

smok1
Yeah, apparently that's the case here.
Mason Wheeler
+4  A: 

Have you verified if the db field which this field represents have a not null constraint?

Fabricio Araujo
*sigh* Of course. That was the problem...
Mason Wheeler
hehehehe... That one happened to me so many times... It's one of the first things I verify... ;-)
Fabricio Araujo
A: 

i don't know if this will help but it sounds familiar. check the properties on the fields of the ado dataset that feeds the cds. i know in d7 the cds internally takes on the readonly property of the provider's dataset regardless of its own readonly setting. the same problem may apply to the required property.

Jozz