这样的query动态设置控件为何出错?请高手们看看!(10分)

  • 主题发起人 libaoliang
  • 开始时间
L

libaoliang

Unregistered / Unconfirmed
GUEST, unregistred user!
这样的query动态设置控件为何出错?请高手们看看!

query1.close;
query1.sql.clear;
query1.sql.add('update cpk set je=:s1+:s2 where pm=:pm');
query1.parambyname('s1').asfloat:=strtofloat(edit1.text);
query1.parambyname('s2').asfloat:=strtofloat(edit2.text);
query1.parambyname('pm').asstring:=edit3.text;
query1.execsql;
..
edit1,edit2,edit3 的内容都符合要求,也就是没有空值
请问为什么错误?系统提示s1,s2 的变量不对!





 
用的是什么数据库
你试一试在程序中先把s1和s2加起来
在sql中用一个参数
另外,参数名与某一个字段的名字一样,会不会有问题
 
最好用一个参数作为金额的值,
query1.sql.add('update cpk set je=:je where pm=:pm');
query1.parambyname('je').asfloat:=strtofloat(edit1.text)+strtofloat(edit2.text);
 
我用的是delphi5.0+paradox
 
query1.close;
query1.sql.clear;
query1.sql.add('update cpk set je=:s1 where pm=:pm');
query1.parambyname('s1').asfloat:=strtofloat(edit1.text)+strtofloat(edit2.text);
query1.parambyname('pm').asstring:=edit3.text;
query1.execsql;

参数名与某一个字段的名字一样不会有问题。
 
同意楼上
 
谢谢弄影:
但为什么 ...je=:s1+:s2 ...出错?


 
同意楼上
 
对于一个字段的动态参数的表示格式我你的是不应许的,其实没有什么太多的道理可讲
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
554
import
I
I
回复
0
查看
927
import
I
顶部