原句是
select convert(varchar(5),convert(numeric(4,2),(Producth.QaNg2+0.05)/Producth.PlanQty*100))+'%'as SumRate from ......
在查询分析器中能够运行,并能得到正确结果,但要在外面加上引号后我就迷茫了?
select convert(varchar(5),convert(numeric(4,2),(Producth.QaNg2+0.05)/Producth.PlanQty*100))+'%'as SumRate from ......
在查询分析器中能够运行,并能得到正确结果,但要在外面加上引号后我就迷茫了?
dateset.sql.add('Select cast((Producth.QaNg2+0.05)/Producth.PlanQty*100)) as varchar(20))+''%'' as SumRate from ......')
select plantqty from ...where productid='65423'不是要写成
dateset.sql.add('select plantqty from ...where productid='''+'65423'+'''')吗?
而不是dateset.sql.add('select plantqty from ...where productid=''65423'')呀!
dateset.sql.add('Select cast((Producth.QaNg2+0.05)/Producth.PlanQty*100)) as varchar(20))+''%'' as SumRate from ......')
select plantqty from ...where productid='65423'不是要写成
dateset.sql.add('select plantqty from ...where productid='''+'65423'+'''')吗?
而不是dateset.sql.add('select plantqty from ...where productid=''65423'')呀!
即 (Producth.QaNg2+0.05)/Producth.PlanQty*100 是数值计算,
而 + ‘%’之后变成了字符运算,
而在DELPHI中程序,他最终被转化为 数值的计算了,所以出现错误了
select plantqty from ...where productid='65423'不是要写成
dateset.sql.add('select plantqty from ...where productid='''+'65423'+'''')吗?
而不是dateset.sql.add('select plantqty from ...where productid=''65423'')呀!