I have two DataCheckbox columns in a DBAdvWebGrid.
When I change the checkboxes value and save I get an Error ' "True" is not a valid boolean for this field". (same for "false").
This happens only when I use the databutton column to edit and save.
If I use the AsyncNavigator saving works fine.
I have a german installation here, but neither modified TTIWDBGridColumn.Checkfalse / Checktrue nor Clientdataset.TBooleanfield.Displayvalues fixed the problem.
Using Windows 7 / Delphi XE4 / IW14.0.25 / TMS IW Pack 5.5
Thank you for any hint on this,
Ronald Krause
Hi,
Thank you for the quick response. I use Postgres 9.2. It accepts 'true', 't', 1,'y', 'yes', ... as boolean.
I digged a litte into the problem and found that in unit DBConst there are these localized resourcestrings:
STextFalse = 'falsch';
STextTrue = 'wahr';
I managed to fix this by using hooking into resource strings (see code below).
Now TBooleanField.DisplayValues defaults to 'true;false' despite the localization.
As a result I can save records from DBAvdWebGrid without modifiying every TBooleanField.DisplayValues or DBAvdWebGrid.Columns.CheckTrue / False.
Problem solved, Great!
Best Regards,
Ronald Krause
unit uResourceModify;
// how to hook into resourcestrings, Credits to Peter Below
// see also http://www.swissdelphicenter.ch/en/showcode.php?id=946
interface
uses Data.DBConsts, WinApi.Windows;
const
NewTrue: PChar = 'true';
NewFalse: PChar = 'false';
procedure HookResourceString(rs: PResStringRec; newStr: PChar);
implementation
procedure HookResourceString(rs: PResStringRec; newStr: PChar);
var
oldprotect: DWORD;
begin
VirtualProtect(rs, SizeOf(rs^), PAGE_EXECUTE_READWRITE, @oldProtect);
rs^.Identifier := Integer(newStr);
VirtualProtect(rs, SizeOf(rs^), oldProtect, @oldProtect);
end;
initialization
HookResourceString(@STextFalse, NewTrue);
HookResourceString(@STextTrue, NewFalse);
end.