我想问问,我现在想向数据库中写入小数的数据,这个数据是用Tedit输入的,我现在用的是ParamByName的写法.因为数据库中的字段定义的是numeric,所以要写小数的数据.
if edtSeg_Length.text<>'' then
ParamByName('seg_length').asfloat:=strtofloat(edtSeg_Length.text)
else
ParamByName('seg_length').asfloat:=Null;
这样的写法对吗?我运行的时候,总是出错.正确的写法是什么样的?谢谢各位了!!
if edtSeg_Length.text<>'' then
ParamByName('seg_length').asfloat:=strtofloat(edtSeg_Length.text)
else
ParamByName('seg_length').asfloat:=Null;
这样的写法对吗?我运行的时候,总是出错.正确的写法是什么样的?谢谢各位了!!
解决方案 »
- 请问,装了DELPHI7后怎么工具栏不正常?
- 关于DBGRID中1个字段的下拉显示子表的问题,麻烦~~~~~~
- 急:如何将db的数据转成oracle的数据库?
- 小弟初学Delphi,有很多问题想请教Delphi高手,本人创建了一个群,欢迎大家来讨论关于Delphi的技术问题!
- 一小段程序不太懂(两句话)
- EXCEL表导入数据库的问题
- 急,请指教,关于文件和文件系统的。
- CSDN宁无人乎???? 50+50==100!!!!---------创建快捷方式!!!!
- 年终奖发了多少,大家都来说说看!!
- 哪位大仙可以解决利用数组的下标为X轴,其中的值为Y轴的动态图表显示!!必有重谢!!
- 问一个弱弱的问题:DCU是什么类型的文件?
- 请问Delphi中如何实现用户自定义的报表?
ParamByName('seg_length').asfloat:=strtofloat(edtSeg_Length.text);
else部分不要了,你试下看.
ParamValues['seg_length']:=strtofloat(edtSeg_Length.text) //strtofloat可能会出错
else
ParamValues['seg_length']:=Null;再给你个函数,就可以使输入框只输入数字,并限制长度、小数位数等procedure MxFormatKeyPress(Text:string;SelStart,SelLength:integer;
var Key:Char;EditType:integer;Digits:integer);
begin
if (Key=#27) or (Key=#8) or (EditType=1) then exit;
if EditType=2 then
if not (Key in ['0'..'9','+','-'] ) then Key:=#0;
if EditType=3 then
if not (Key in ['0'..'9','+','-','.'] ) then Key:=#0;
//控制+-
if (Key ='-') or (Key='+' ) then
begin
if ((Pos('-',Text) > 0) or (Pos('+',Text) > 0 )) and
(SelLength=0 ) then Key:=#0;
if SelStart > 0 then Key:=#0;
end;
//控制.
if (Key = '.') and (EditType=3 ) then
begin
if (Pos('.',Text) > 0) and (not((SelStart=Pos('.',Text) ))) then Key:=#0;
if SelStart=0 then Key:=#0;
if (Digits>0) and (SelStart+SelLength>0) and (EditType=3) then exit;
end;
if (pos('.',Text )>0 ) and (SelStart>=pos('.',Text)) then
if length(Text)-pos('.',Text )>=Digits then Key:=#0;
end;