还是不行啊!再度请教sql与edit中的加减问题!(10分)

Y

yyjqtww

Unregistered / Unconfirmed
GUEST, unregistred user!
SQL.Text := 'update ykucuntab set total=total+'+ strtoint(edit8.text) + ' where isbn='+''''+edit2.text+''''+'';
运行还是出错
[Error] Unit16.pas(116): Incompatible types: 'String' and 'Integer'
 
'+ strtoint(edit8.text) + '
把上面两个引号去掉
 
isbn是什么类型?
SQL.Text := 'update ykucuntab set total=total+'+ strtoint(edit8.text) + ' where isbn='+edit2.text;
 
实在不行你先将值相加再更新:
total:=total+strtoint(edit8.text);
sql.text:='update ykucuntab set total=total ...
如果isbn是integer,则按楼上这位兄台的。
 
Text 为String类型,你的
'update ykucuntab set total=total+'+
strtoint(edit8.text) + //这怎么冒出个整数类型?????
' where isbn='+''''+edit2.text+''''+''
正确答案:
'update ykucuntab set total=total+'+
edit8.text+ //去掉转换
' where isbn='+''''+edit2.text+''''+''
 
同意楼上
 
Incompatible types: 'String' and 'Integer':性质相反的类型
'update ykucuntab set total=total+'+ strtoint(edit8.text)
//'update ykucuntab set total=total'是String 类型,strtoint(edit8.text)却把str
转换为integer ,String 不能与integer 加起来
所以edit8.text 的值没必要转换
 

SQL.Text := 'update ykucuntab set total=total+'+ edit8.text + ' where isbn='+''''+edit2.text+'''';
 
因为是串在加,所以edit8现不要转换啊!!
 
多人接受答案了。
 
顶部