Hi,
I have a very simple code that works ok, but the ApplyUpdates don't have effect. This is the code:
procedure TFormPhonesFormat.ButtonBeginClick(Sender: TObject);
var
Phone: String;
FieldName: String;
begin
FieldName := 'Phone';
Table1.First;
while not Table1.Eof do
begin
if Table1.FieldByName(FieldName).OldValue <> null then
begin
Phone := Table1.FieldByName(FieldName).OldValue;
Phone := StringReplace(Phone, '(', '', [rfReplaceAll, rfIgnoreCase]);
Phone := StringReplace(Phone, ')', '', [rfReplaceAll, rfIgnoreCase]);
Phone := StringReplace(Phone, '-', '', [rfReplaceAll, rfIgnoreCase]);
Phone := StringReplace(Phone, ' ', '', [rfReplaceAll, rfIgnoreCase]);
Table1.Edit;
Table1.FieldByName(FieldName).NewValue := Phone;
end;
Table1.Next;
end;
Database1.ApplyUpdates([Table1]);
end;
Apparently everything is ok, but nothing change in Table1 after executing the code.
Thanks in advance.
I have a very simple code that works ok, but the ApplyUpdates don't have effect. This is the code:
procedure TFormPhonesFormat.ButtonBeginClick(Sender: TObject);
var
Phone: String;
FieldName: String;
begin
FieldName := 'Phone';
Table1.First;
while not Table1.Eof do
begin
if Table1.FieldByName(FieldName).OldValue <> null then
begin
Phone := Table1.FieldByName(FieldName).OldValue;
Phone := StringReplace(Phone, '(', '', [rfReplaceAll, rfIgnoreCase]);
Phone := StringReplace(Phone, ')', '', [rfReplaceAll, rfIgnoreCase]);
Phone := StringReplace(Phone, '-', '', [rfReplaceAll, rfIgnoreCase]);
Phone := StringReplace(Phone, ' ', '', [rfReplaceAll, rfIgnoreCase]);
Table1.Edit;
Table1.FieldByName(FieldName).NewValue := Phone;
end;
Table1.Next;
end;
Database1.ApplyUpdates([Table1]);
end;
Apparently everything is ok, but nothing change in Table1 after executing the code.
Thanks in advance.