Lazarus

Programming => General => Topic started by: jptferreira on May 21, 2019, 07:45:05 pm

Title: (SOLVED) - Check database field value with if statement.
Post by: jptferreira on May 21, 2019, 07:45:05 pm
I'd like recommendation for the best way to get a value from a selected database field and check if it is True or False to then act upon the result.
example:
if databasefield = 'True' then show menu item
Using pascal I don't know how to check if the selected database field has the content True or False.

The IF statement is required but I'm having a hard time finding the best solution.
Any help!  :D
Title: Re: Check database field value with if statement.
Post by: valdir.marcos on May 21, 2019, 09:16:41 pm
I'd like recommendation for the best way to get a value from a selected database field and check if it is True or False to then act upon the result.
example:
if databasefield = 'True' then show menu item
Using pascal I don't know how to check if the selected database field has the content True or False.
The IF statement is required but I'm having a hard time finding the best solution.
Any help!  :D
One possibility:
Code: Pascal  [Select]
  1.   if (SQLQuery1.FieldByName('LogicalField').AsBoolean) then
  2.   begin
  3.     // true...
  4.   end
  5.   else
  6.   begin
  7.     // false...
  8.   end;
  9.  
Title: Re: Check database field value with if statement.
Post by: jptferreira on May 21, 2019, 10:01:26 pm
Thank you! :D