读书人

like +#039;#039;#039;+text1.text+#039;#039;#039;+#039;%#039;#039;#039;这三个

发布时间: 2012-03-06 20:47:55 作者: rapoo

like +'''+text1.text+'''+'%'''这三个撇怎么分,
(1) Adodc4.RecordSource= "select * from 稿费发放表 where 刊物名称

like + ' ' '+text1.text+ ' ' '+ '% ' ' ' "

(2) Adodc4.RecordSource= "select * from 稿费发放表 where 刊物名称

like ' ' '+text1.text+ ' ' '+ '% 'and 年= ' ' '+text2.text+ ' ' '+ '% ' and 期

= ' ' '+text3.text+ ' ' '+ '% ' "

这三个撇,是 先一个单引号,在是一个双引号;还是先是一个双引号,在是一个单引号??

(1)和(2)中like 后边先加一个 + 与 先加 ' ' ' 有什么区别,是什么意思??


[解决办法]
1、Adodc4.RecordSource= "select * from 稿费发放表 where 刊物名称 like ' " + text1.text + "% ' "

2、Adodc4.RecordSource= "select * from 稿费发放表 where 刊物名称 like ' " + text1.text + " '% 'and 年= ' " + text2.text + " '% ' and 期
= ' " + text3.text + " '% ' "

[解决办法]
2、Adodc4.RecordSource= "select * from 稿费发放表 where 刊物名称 like ' " + text1.text + "% ' and 年= ' " + text2.text + "% ' and 期
= ' " + text3.text + "% ' "

感觉多了几个单引号~~VB里SQL就是组合字符串~~~把段点设在adodc4.refresh上,把adodc4.recordsource 打印出来看看就知道了~~
[解决办法]
以上写的可以将“+”改为“&”这样会更清楚点
[解决办法]
(1) Adodc4.RecordSource= "select * from 稿费发放表 where 刊物名称

like ' " & text1.text & "% ' "

(2) Adodc4.RecordSource= "select * from 稿费发放表 where 刊物名称

like ' " & text1.text & "% 'and 年= ' " & text2.text & "% ' and 期

= ' " & text3.text & "% ' "

[解决办法]
如果“年”字段在数据库里是整型就不用加单引号了,另外,既然用了 年= ,还用加 % 么

读书人网 >VB

热点推荐