#1 2015-07-17 15:24:11

mike76
Member
Registered: 2015-06-16
Posts: 18

TSynDBDataSet(ds1.DataSet).ApplyUpdates issue

ab, As you already know we are using TSynDBDataSet in our project smile

We are experiencing a quite odd issue when using TSynDBDataSet(ds1.DataSet).ApplyUpdates(0), the changes are not applied if the row contains a column with empty string, but it's not NULL.

For example we are inserting rows:

    fProps.ExecuteNoResult(
      'INSERT INTO MyData (column1, column2, column3) '+
      'VALUES (?,?,?)',
      [WideStringToUTF8(myvalue1),
       WideStringToUTF8(myvalue2),
       WideStringToUTF8(myvalue3)
      ]);

If myvalue3='' (empty string), when we made changes to the row and TSynDBDataSet(ds1.DataSet).ApplyUpdates(0), the changed don't commit. There is no error message.
If we change the value of the column3, to not be empty, commit will work.

The only way to fix this issue is to not add the column3 to the INSERT statement if myvalue3 is empty.

Is there any other way we could fix it?
When the string it's empty, insert to set NULL value for that column.

Thanks

Offline

#2 2016-04-28 12:39:23

sevo
Member
Registered: 2015-11-10
Posts: 27

Re: TSynDBDataSet(ds1.DataSet).ApplyUpdates issue

In my case (ODBC-Connection), the changes are applied, but the inserted value is 'null'.
It is not possible to set an empty string or clear the field.

E.g. FieldByName('Field').AsString = '' -> inserts the string 'null'
and FieldByName('Field').Clear -> insterts the string 'null', too.

It ends up in TSQLDBStatement.BindVariant, Default (no match for TVarData(Data).VType) -> VariantToUTF8(undefined) -> 'null'

Is it possible to keep TDataSet-Compatibility here?

Offline

Board footer

Powered by FluxBB