Hi
I had a weird situation which waste a lot of hours only because the exception error was incorrect !!
I have a table (TIBCQuery component) that one of its fields defined as not null foreign key to another table ID1. and after insert I set the ID1 value of the first table to the ID1 value of the foreign key table.
The result is exception error message "field ID1 must have a value". I did trace to the code and found a previous exception message appear even before this one (appear only at debugging): "Field ID1 does not exist" !! I checked the table select SQL many times and found it correct! I even rewrite the table whole SQL that link with other foreign key tables but I always find the SQL is correct and the field ID1 exists !!
Finally I notice I did not set a flag responsible for making this table open in a config file that because I use the same table between 3 different applications.
However my point if I get an exception error message like "table is not open" I could solve the problem in a minute instead of wast precious hours so I hope this can be enhanced.
Incorrect error message
-
AndreyZ
Re: Incorrect error message
Hello,
The "Field 'FieldName' must have a value" error occurs because the RequiredFields option of the TIBCQuery is set to True by default. When RequiredFields is True, all NOT NULL fields are created with the Required property set to True. It is a client-side error that is generated by the TDataSet.CheckRequiredFields method. It is a correct behaviour. To avoid this error, you should set RequiredFields to False.
The "Field 'FieldName' must have a value" error occurs because the RequiredFields option of the TIBCQuery is set to True by default. When RequiredFields is True, all NOT NULL fields are created with the Required property set to True. It is a client-side error that is generated by the TDataSet.CheckRequiredFields method. It is a correct behaviour. To avoid this error, you should set RequiredFields to False.
Re: Incorrect error message
I get better descriptive error message when requiredfields is set to true and this will be useful for the end users that are usually are novice users. they can understand "Field Name must have a value" but they wont understand field name is null or similar and it will save me alot of time from checking all required fields manually from code.
The CheckRequiredFields method should check if the dataset is open first so is it possible to override this method to make check if the dataset is open or not ?
it will be a good enhancement.
The CheckRequiredFields method should check if the dataset is open first so is it possible to override this method to make check if the dataset is open or not ?
it will be a good enhancement.
-
AndreyZ
Re: Incorrect error message
The CheckRequiredFields method is a private non-virtual method of the TDataSet class, so there is no way to override it.
It is not clear for us what error messages you want to obtain. Please describe the exact error messages and the exact situations they must occur in.
It is not clear for us what error messages you want to obtain. Please describe the exact error messages and the exact situations they must occur in.
Re: Incorrect error message
I see.
After call to insert method for the TIBCQuery I get error message "field ID1 must have a value" then on debugging I get this exception message even before the previous one: "Field ID1 does not exist" but appear only at debugging.
At the end I found that the problem was table (TIBCQuery component) was not open so when I try to insert I should get error like: "can not do that action on closed dataset"
My first post have the steps I followed.
Thanks
After call to insert method for the TIBCQuery I get error message "field ID1 must have a value" then on debugging I get this exception message even before the previous one: "Field ID1 does not exist" but appear only at debugging.
At the end I found that the problem was table (TIBCQuery component) was not open so when I try to insert I should get error like: "can not do that action on closed dataset"
My first post have the steps I followed.
Thanks
-
AndreyZ
Re: Incorrect error message
Please try creating a small sample to demonstrate this problem and send it to andreyz*devart*com , including a script to create all needed server objects (tables, triggers, etc.).