query1.sql.add('update animals set weight=20 where name=boa');这样写为什么不行呢?
解决方案 »
- dll编程Access violation at address的问题
- 如何用代码打印ACCESS报表
- 如何判断一个字符类型的字段里的字符只是数字?
- 如何截获外程序按钮的被点击消息?顺便再问问如何更好的实现下面的程序!!!
- 怎样将mdac2.7也打包上
- 怎样查询字符串???
- 那里有 LeadTools v14 可以下载!
- "OLE服务无法绑定对象",请问各位高手这是什么意思?
- 将memo内容导出到EXCEL时如果自动识别换行???
- 请问,誰有SQL SERVER中关于Formula(公式)的详细说明?那帮助文件不知所云
- 急,高分求教!TTS如何转化成WAV?
- 怎样对表中的"GRAPHIC"的字段进行付值?
query1.close;
query1.sql.clear;
query1.sql.add('update animals set weight=20 where name=boa');
query1.execsql;
另外如过name 是字符的 那么
query1.sql.add('update animals set weight=20 where name="boa"');
你该将条件语句中的字符串常量用引号括起来的,比如
你要构造的更新语句为
update animals set weight=20 where name='boa';
那么我们必须改成
query1.sql.add('update animals set weight=20 where name='+''''+'boa'+'''');//delphi中要得到‘''的字符串,
必须这样写''''.
你可以试试。
with query1 do
begin
close;
sql.Clear;
sql.Add('update animals set weight=58 where name='+''''+'boa'+'''');
execsql;
改成这两句也不行~~
sql.Add('update animals set weight=58 where name="boa"');
sql.Add('update animals set weight=58 where name='boa'');
sql.Add('update animals set weight=58 where name=''boa''');
boa两边都是但引号,绝对可以的