读书人

这条语句老报错提示quot;[Error] Unit1.

发布时间: 2012-09-17 12:06:51 作者: rapoo

这条语句老报错,提示"[Error] Unit1.pas(34): Missing operator or semicolon"
form1.adoquery1.sql.add('select * from table1 where aa>'''+strtoint(edit1.text)'');



我想肯定是引号的个数出了问题,这引号到底是怎么分配的?1个跟3个有什么区别?

[解决办法]

Delphi(Pascal) code
2个变1个,成对出现.add('select * from table1 where aa>'''+strtoint(edit1.text)+'''');可以用Quotedstr函数处理.add('select * from table1 where aa>'+Quotedstr(strtoint(edit1.text)));
[解决办法]
哦,没注意到strtoint,这是错的,不需要转换

aa字段是字符类型
.add('select * from table1 where aa>'''+edit1.text+'''');
因为要拼接成符合SQL语法,所以就要这么加引号了
最终语句是这样
select * from table1 where aa>'Hello'

aa字段是数字类型,引号不用,但要判断edit1输入值是数字
.add('select * from table1 where aa>'+edit1.text);

读书人网 >.NET

热点推荐