I've got a serious problem with SDAC and TMemoFields. In SQL Server database I have a field 'some_text' (text, not null) and if I try to set the FieldValue to '' (empty) then it is sent as null and I get an exception.
Steps to reproduce:
The table conatins a record (id,...,some_text,...)=(1,...,'',....)
Code: Select all
MsQuery.SQL.Text := 'select * from my_table where id=1';
MsQuery.Open;
MsQuery.FieldValues['some_text'] = '' [OK]
MsQuery.FieldByName('some_text').IsNull = false [OK]
Code: Select all
MsQuery.Edit;
MsQuery.FieldValues['some_text'] := '';
MsQuery.FieldValues['some_text'] = '' [OK]
MsQuery.FieldByName('some_text').IsNull = true [WRONG]
Code: Select all
MsQuery.Post;
Cannot insert the value NULL into column 'some_text', table 'mydb.dbo.my_table; column does not allow nulls. UPDATE fails.
The same problem exists also with calling Append/Post but only with TMemoFields, with TStringFields everything is OK.
I see this as some kind of a global DAC issue with TMemoFields, because the same situation occurs in MyDac (IsNull=true) but at least the Post doesn't raise an exception there.
Regards,
Crafty