急!数据库的数据为0,查询出来的数据会出现类似-1.53e的东西!(100分)

  • 主题发起人 主题发起人 fjqzcb
  • 开始时间 开始时间
F

fjqzcb

Unregistered / Unconfirmed
GUEST, unregistred user!
问题:数据库的数据为0,但查询出来的数据会出现类似-1.53e的东西!
代码如下:
with DM.jxDS_ADS2 do begin
CommandText:='select sum(MTotal)/100 as jxMTotal, sum(MHelp)/100 as jxMHelp, '
+'sum(MSelf)/100 as jxMSelf from Bill '
+'where PDate>=:NewValueParam1 and PEnable and '
+'PDate<=:NewValueParam2 and KPName=:KPNParam';
Parameters.ParamByName('NewValueParam1').Value :=FormatDateTime('yyyy-m-d',DTPicker1.Datetime);
Parameters.ParamByName('NewValueParam2').Value :=FormatDateTime('yyyy-m-d',DTPicker2.Datetime);
Parameters.ParamByName('KPNParam').Value :=combobox1.Text;
end;

with DM.jxDS_ADS4 do begin
CommandText:='select sum(MCard)/100 as jxMCard from Bill '
+'where PDate between :NewValueParam1 and '
+':NewValueParam2 and KPName=:KPNParam';
Parameters.ParamByName('NewValueParam1').Value :=FormatDateTime('yyyy-m-d',DTPicker1.Datetime);
Parameters.ParamByName('NewValueParam2').Value :=FormatDateTime('yyyy-m-d',DTPicker2.Datetime);
Parameters.ParamByName('KPNParam').Value :=combobox1.Text;
end;

edit1.Text:=floattostr(DM.jxDS_ADS2.FieldValues['jxMTotal']
-DM.jxDS_ADS2.FieldValues['jxMHelp']
-DM.jsDS_ADS4.FieldValues['jxMCard']);
 
怎么没有看到你的OPEN
还有赋值CommandText前先关闭,赋值后参数要refresh,然后open
 
与字段类型有关,浮点精度问题.也属正常.
如果是显示需要的话,设置显示格式即可.
如果是数值比较,建议比较二个数的差值的绝对值,看它是否处于某个数值范围.
 
To xinjinren:有open 没贴出来
To xinjinren:能不能详细一点?比较二个数的差值的绝对值,看它是否处于某个数值范围,要如何比较,能不能举个例子,谢谢!
 
比如: var a,b : double;
if abs(a - b) <= 0.0001 then 认为a和b的值是相等的
if abs(a) <= 0.0001 then 认为a就是0值
上面0.0001是个参考值,根据你实际需要的精度来确定
 
后退
顶部