这条话语老报错,提示"[Error] Unit1.pas(34): Missing operator or semicolon"
这条语句老报错,提示"[Error] Unit1.pas(34): Missing operator or semicolon"
form1.adoquery1.sql.add('select * from table1 where aa>'''+strtoint(edit1.text)'');
我想肯定是引号的个数出了问题,这引号到底是怎么分配的?1个跟3个有什么区别?
------解决思路----------------------
------解决思路----------------------
哦,没注意到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);
form1.adoquery1.sql.add('select * from table1 where aa>'''+strtoint(edit1.text)'');
我想肯定是引号的个数出了问题,这引号到底是怎么分配的?1个跟3个有什么区别?
------解决思路----------------------
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);