str:='select * from 表 where 姓名 like '+''''+'%'+edit1.Text +'%'+''''; 感觉怎么好像写错了 str:='select * from 表 where 姓名 like '+'''+'%'+edit1.Text +'%'+'''; 看看 是不是该这样
楼主教你一个好办法。 由于在写SQL语句的时候~'''表示一个‘号~此时看起来太费力气~ 我一般用#39来表示“'”号~非常好用。我一直这么用。 像你的SQL可以写成。 str:='Select * from 表 where 姓名 like'+'%'+#39+Edit1.Text+#39+'%'; 这样就可以了,这样非常清楚还不容易出错~ 嘻嘻~~给我分哦~~ str:='select * from 表 where 姓名 like '+''''+'%'+edit1.Text +'%'+'''';
呵呵~~写错了SQL~ str:='Select * from 表 where 姓名 like'+#39+'%'+Edit1.Text+'%'+#39;
哈哈,多谢各位 最佳方法str:='Select * from 表 where 姓名 like '+ Quotedstr('%' + trim(edit1.text) + '%')
为什么不用Format str:='select * from 表 where 姓名 like '+''''+'%'+edit1.Text +'%'+''''; <=>str:= Format('select * from 表 where 姓名 like %s', [''''+ '%' + edit1.text + '%s' + '''']);
'select * from 表 where 姓名 like "%'+edit1.Text +'%"' if edit1.text is "a" finded is jfkgjkjfagfkfk or ituriuavmvbvbvbvb........ - -
str:='select * from 表 where 姓名 like '+''''+'%'+edit1.Text +'%'+''''; 改str:='select * from 表 where 姓名 like ''%'edit1.Text+'%''''
太简单了 str:='select * from 表 where 姓名 like '+''''+'%'+edit1.Text +'%'+'''';'select * from 表 where 姓名 like '是字符串select * from 表 where 姓名 like 部分 ''''+'%'是字符串双引号与%的组合 "% 部分 EDIT1.TEXT是EDIT1设定的字符串值 '%'+''''是字符串%与双引号的组合 %" 部分连起来为字符串表述为 select * from 表 where 姓名 like "%edit1.Text%"; %两边的"是通过'括起来的
ADOQueryPoison.Close; ADOQueryPoison.SQL.Text:='select * from Poison where 中文名称 like ''%' +EPoisonName.Text+ '%'''; ADOQueryPoison.Open;
在Delphi中单引号还有一个作用,就是做为强制转换符来使用,四个单引号中的第2个就是一个强制转换符,它会将第三个单引号做为整个字符中的一个字符来对待,而不是这字符连接时用的单引号了,所以经过编译后,你的str的值就该是(假设你的edit1.text的值是“张”) select * from 表 where 姓名 like '%张%'
str:='Select * from 表 where 姓名 like '+ Quotedstr('%' + trim(edit1.text) + '%')
感觉怎么好像写错了
str:='select * from 表 where 姓名 like '+'''+'%'+edit1.Text +'%'+''';
看看 是不是该这样
由于在写SQL语句的时候~'''表示一个‘号~此时看起来太费力气~
我一般用#39来表示“'”号~非常好用。我一直这么用。
像你的SQL可以写成。
str:='Select * from 表 where 姓名 like'+'%'+#39+Edit1.Text+#39+'%';
这样就可以了,这样非常清楚还不容易出错~
嘻嘻~~给我分哦~~
str:='select * from 表 where 姓名 like '+''''+'%'+edit1.Text +'%'+'''';
str:='Select * from 表 where 姓名 like'+#39+'%'+Edit1.Text+'%'+#39;
最佳方法str:='Select * from 表 where 姓名 like '+ Quotedstr('%' + trim(edit1.text) + '%')
str:='select * from 表 where 姓名 like '+''''+'%'+edit1.Text +'%'+''''; <=>str:= Format('select * from 表 where 姓名 like %s', [''''+ '%' + edit1.text + '%s' + '''']);
if edit1.text is "a" finded is jfkgjkjfagfkfk or ituriuavmvbvbvbvb........
- -
改str:='select * from 表 where 姓名 like ''%'edit1.Text+'%''''
str:='select * from 表 where 姓名 like '+''''+'%'+edit1.Text +'%'+'''';'select * from 表 where 姓名 like '是字符串select * from 表 where 姓名 like 部分
''''+'%'是字符串双引号与%的组合 "% 部分
EDIT1.TEXT是EDIT1设定的字符串值
'%'+''''是字符串%与双引号的组合 %" 部分连起来为字符串表述为 select * from 表 where 姓名 like "%edit1.Text%";
%两边的"是通过'括起来的
ADOQueryPoison.SQL.Text:='select * from Poison where 中文名称 like ''%' +EPoisonName.Text+ '%''';
ADOQueryPoison.Open;
select * from 表 where 姓名 like '%张%'