hello, im starting with devart mysql component for delphi and im having a problem with empty dbedits, here it goes:
in the Client Inserting form i have a DBEdit linked to column email by a MyQuery -> DataSource -> DBEdit
I need that MyQuery pass the value null to the database and not a blank value, because this field (email) is set 'not null' , and the blank value sent by MyQuery bypasses the blockage of 'not null' of the database..
(In my form i have a button register, when i click it, and a required field is not supplied, MySQL return a error and the button have a error handler, that block user to finish the register, but the database only return a error when i sent a NULL value, but MyQuery is sending as Blank value ' ')
how to send a null value to the database when the dbedit is not supplied?
Sorry bad english
thanks...
empty DBEdit in VARCHAR column
To solve this problem you may handle the TMyQuery.BeforeUpdateExecute event and check the set value of the 'email' field, like this:
Code: Select all
if Params.FindParam('email') nil then
if Params.ParamByName('email').AsString = '' then
Params.ParamByName('email').Clear;