在vb程序 select * from table where xm=text1.text and bh=text2.text,为什么只判断第一个条件?

来源:百度知道 编辑:UC知道 时间:2024/05/29 19:51:54
我是这样写的"select * from table where xm='"+text1.text+"' and bh='"+text2.text+"'"可是只执行第一个条件???

上述写法不对,text1.text和text2.text需用单引号括起来,并且这里text1.text和text2.text并不是字符串,而是控件,变量,容器,应放在双引号之外,所以应写成:
"select * from table where xm='" & text1.text & "' and bh='" & text2.text & "'"

通常格式如下:

sql="select * from table where xm='" & text1.text & "' and bh='" & text2.text & "'"

sql = "select * from table where xm ='" & Text1.Text & "' and bh ='" & Text2.Text & "'"