Modifying FieldValues programmatically

Risto

Member
Hello,
I have a dialog with several TDBEdit controls associated with fields in a TOracleDataSet. When the user closes the dialog I calculate a date value and assign it to a field in the same dataset, like this:
MySet['VERSION_DATE'] := dtpDate.Date;
Now when ApplyUpdates is called the value in VERSION_DATE field is NOT transferred to database but it is restored back to what it was before the assignment. But this happens only if control values in the dialog have not been changed. If the user modifies contents of one or more of the TDBEdit controls then the modified values are correctly updated in database AND value of field VERSION_DATE is updated, too! So it seems to me that TOracleDataset does not 'know' that a record has been modified if it is not modified using data-aware controls. How can I tell the recordset that value of a field has been modified programmatically and needs to be updated to database?

Risto
 
Risto, before calling your code check if the dataset is in edit mode, and if not then put it into edit mode, ie:

If not (OracleDataSource1.State) in [dsEdit,dsInsert] then
OracleDataSource1.Dataset.Edit;
//Do as before
 
It helped! So changing data in a data-aware control takes the associated dataset automatically to edit state but if the data is changed programmatically then the dataset state must be changed manally in code.

Thank you very much, Robertio.

Risto
 
Back
Top