2
0
Эх сурвалжийг харах

* set BCD and time fields to NULL when an empty string is passed. Mantis #21204, patch by Ludo

git-svn-id: trunk@20208 -
marco 13 жил өмнө
parent
commit
2cfb20db60

+ 15 - 4
packages/fcl-db/src/base/fields.inc

@@ -2167,8 +2167,13 @@ end;
 procedure TTimeField.SetAsString(const AValue: string);
 Var R : TDateTime;
 begin
-  R:=StrToTime(AVAlue);
-  SetData(@R);
+  if AValue='' then
+    Clear    // set to NULL
+  else
+    begin
+    R:=StrToTime(AVAlue);
+    SetData(@R);
+    end;
 end;
 
 
@@ -2483,7 +2488,10 @@ end;
 procedure TBCDField.SetAsString(const AValue: string);
 
 begin
-  SetAsCurrency(strtocurr(AValue));
+  if AValue='' then
+    Clear    // set to NULL
+  else
+    SetAsCurrency(strtocurr(AValue));
 end;
 
 constructor TBCDField.Create(AOwner: TComponent);
@@ -2664,7 +2672,10 @@ end;
 
 procedure TFMTBCDField.SetAsString(const AValue: string);
 begin
-  SetAsBCD(StrToBCD(AValue));
+  if AValue='' then
+    Clear    // set to NULL
+  else
+    SetAsBCD(StrToBCD(AValue));
 end;