Null value for blank in a grid

mrmitch

Member
I have a column with a NOT NULL constraint:
ex) PREDIR VARCHAR2(2) NOT NULL

I have a DBGrid attached to a DataSet and when I try and enter a space character in a field, something internal treats this space as a NULL and refuses to update since it doesn't follow the constraint.

Any idea for workarounds? I don't want to store a NULL in the field and I do want a space to be a valid value in the field.

The Dataset.BeforePost event has the following code:
if DataSet.FieldByName('PREDIR').AsString = '' then DataSet.FieldByName('PREDIR').AsString := ' ';

But the space gets stripped somewhere after this code executes.
 
The TOracleSession.Preferences.TrimStringFields property controls if trailing spaces are removed from dataset fields. It is True by default, so you probably need to set it to False to fix the problem.

------------------
Marco Kalter
Allround Automations
 
Wow, I looked at that property several times and never saw that option. Thank you very much. You have an excellent product!

- Mitch

Originally posted by mkalter:
The TOracleSession.Preferences.TrimStringFields property controls if trailing spaces are removed from dataset fields. It is True by default, so you probably need to set it to False to fix the problem.

 
Back
Top