Field.AsString := '' must set Field to Null
Field.AsString := '' must set Field to Null
Hi,
I am using Delphi 2010 with IBDAC 3.10.0.8. I have found a serious bug:
IBCTable1.FieldByName('myField').AsString := '';
must set the Field to NULL. But it sets the field to an emtpy string. Please correct this. Setting the fieldvalue to null is the default behavior of delphi and other db-access libraries. myField is a StringField (Unicode).
Thank you!
I am using Delphi 2010 with IBDAC 3.10.0.8. I have found a serious bug:
IBCTable1.FieldByName('myField').AsString := '';
must set the Field to NULL. But it sets the field to an emtpy string. Please correct this. Setting the fieldvalue to null is the default behavior of delphi and other db-access libraries. myField is a StringField (Unicode).
Thank you!
To set the NULL value in the field, you should call the Clear method, like this:
Code: Select all
IBCTable1.FieldByName('myField').Clear;
This is too circumstantial. I have many codefragments where I use something like IBCTable1.FieldByName('myField').AsString := MyVar or something like IBCTable1.FieldByName('myField').AsString := myTEdit1.text. I don't know the content of MyVar. It can be a filled string or empty string. My Application has more than 2 Million lines of code. Its to circumstantial to search all occurances of IBCTable1.FieldByName('myField').AsString := myTEdit1.text and replace it withDimon wrote:To set the NULL value in the field, you should call the Clear method, like this:Code: Select all
IBCTable1.FieldByName('myField').Clear;
if myTEdit1.text = '' then
IBCTable1.FieldByName('myField').Clear
else
IBCTable1.FieldByName('myField').AsString := myTEdit1.text
An other reason why IBCTable1.FieldByName('myField').AsString := ''; must set the field to NULL is:
An empty TDBEdit must also write null into the DB, but with IBDAC it writes an empty string. Delphi (IBX or BDE) and all other known DB-access components writes NULL.
Hi devart-team,l_vaskov wrote:+1BlueMoon wrote: An other reason why IBCTable1.FieldByName('myField').AsString := ''; must set the field to NULL is:
An empty TDBEdit must also write null into the DB, but with IBDAC it writes an empty string. Delphi (IBX or BDE) and all other known DB-access components writes NULL.
where is your answer to this? As you can see other people need this too. Just drop a TDBEdit on your form an connect it via IBDAC to a firebird db. You dont have to wirte any code to see the error: Posting an empty TDBEdit writes an empty string to the table. But ist must be NULL! Please correct this! Thank you in advance!
We are investigating possibility of adding new feature for replacing empty strings to NULL on set fields and parameters values. We can add managing this behavior to connection options or as global variable. But managing this behavior in the connection options has one limitation: you cannot change behavior of a dataset that doesn't have connection (the connection property is empty). The global variable also has limitation: you cannot change behavior in the design-time. We want to know your opinion: where it will be easy to use - when you can change behavior in the connection options or in the global variable.
Hi Dimon,
thanks for the quick reply. Some things are not clear to me:
In which cases someone uses a dataset without a connection (the connection property is empty)? Without a connection it doesnt work. And the other Question is: If we use a global variable why should I change the behavior at design-time? Writing null-values are needed only at run-time. At this moment I think to implement it in the connection options would be better, because its easier to find as a global variable and you can set it at design-time. I think datasets have alsway a connction, so this is not a point against it. Or am I'am wrong?
thanks for the quick reply. Some things are not clear to me:
In which cases someone uses a dataset without a connection (the connection property is empty)? Without a connection it doesnt work. And the other Question is: If we use a global variable why should I change the behavior at design-time? Writing null-values are needed only at run-time. At this moment I think to implement it in the connection options would be better, because its easier to find as a global variable and you can set it at design-time. I think datasets have alsway a connction, so this is not a point against it. Or am I'am wrong?