ParambyName - how to string lazarus / 16-Databases ---------------------------------------------------------------------- Nicole · 2025-03-26 12:44 There is a TEdit, with a Caption of 14,588980 So a string-value The database awaits a type of Decimal 5,2 so the allowed entry would be 14.59 Question about "ParambyName....AsFloat" 1) , instead of . would be a bad idea, right? There are strictly no formatted stings in any way allowed to use, right? 2) What about "14,588980". Would the "as float" convert this to me by itself into 13,59 or will I have to find it by myself. So can I paste a string value "asFloat" and it works? 3) Depending on the answer of question 2: What is the best way to do it? We have a string, which shall become a double. ---------------------------------------------------------------------- Leledumbo · 2025-03-26 13:05 In preference order: Ensure both client and server uses the same localeModify DefaultFormatSettings to follow server's localeManual conversion (e.g. FormatFloat) ---------------------------------------------------------------------- Zvoni · 2025-03-26 14:04 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1;{$mode objfpc}{$H+}Uses SysUtils;Var  TF:TFormatSettings;  s:String;  f:Double;  b:Boolean;begin  TF.DecimalSeparator:=',';  s:='14,588980';  b:=TryStrToFloat(s,f,TF);  Writeln(Round(f*100)/100.0);      Readln;end. Boils down to: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i b:=TryStrToFloat(s, f,TF);    If b Then MyQuery.ParamByName('MyFloatParam').AsFloat:=Round(f*100)/100.0; Quote from: Leledumbo on March 26, 2025, 02:05:45 pmIn preference order: Ensure both client and server uses the same localeModify DefaultFormatSettings to follow server's localeManual conversion (e.g. FormatFloat)Have to disagree with the first 2 points. A Float is a Float. Period. As such it will always have the "." as decimal separator for the numeric (float) Data within the Database. It has nothing to do with a locale of the Server. Data is Data. A locale chips in, when it comes to DISPLAYING resp. Conversion of the displayed "Value" to the Value the Database understands The Server might be in the USA, the Client is in Germany. The only thing of interest is the locale of the Client. Since the Data in Question resides in a TEdit, it's a String out of the Gates, meaning you need (manual) conversion, in which the client's locale chips in with its Decimal Separator (See my code-snippet above) ---------------------------------------------------------------------- tonyw · 2025-03-27 10:13 Quote from: Nicole on March 26, 2025, 01:44:59 pm3) Depending on the answer of question 2: What is the best way to do it? We have a string, which shall become a double. The point to remember is that if you set a numeric parameter as a string then the string is passed to the Firebird server which then attempts to decode it to a numeric value. This will typically use its default local when differentiating between a decimal point or comma. When you decode that string locally (e.g. using StrToFloat) then your local locale is used to differentiate between a decimal point or comma. Personally, I would always decode locally. That way it works regardless of where the server is located or how it has been set up (assuming that your local locale is set appropriately). ---------------------------------------------------------------------- Nicole · 2025-04-08 09:11 Quote from: Nicole on March 26, 2025, 01:44:59 pmThere is a TEdit, with a Caption of 14,588980 So a string-value The database awaits a type of Decimal 5,2 so the allowed entry would be 14.59 Question about "ParambyName....AsFloat" 1) , instead of . would be a bad idea, right? There are strictly no formatted stings in any way allowed to use, right? 2) What about "14,588980". Would the "as float" convert this to me by itself into 13,59 or will I have to find it by myself. So can I paste a string value "asFloat" and it works? 3) Depending on the answer of question 2: What is the best way to do it? We have a string, which shall become a double. ---------------------------------------------------------------------- Zvoni · 2025-04-08 09:13 Is there a question?