热血江湖140武器:str = "select * from yuangongxinxi where 部门="Text1.Text"and 性别='女'

来源:百度文库 编辑:高考问答 时间:2024/05/05 15:55:01
为什么不可以
str = "select * from yuangongxinxi where 部门="Text1.Text"and 性别='女'

什么语言啊?
VB里应该是这样的吧
str = "select * from yuangongxinxi where 部门='" & Text1.Text & "' and 性别='女' "

这个问题在各种变成语言都存在 主要就是字符 " ' 的使用

比如vb字符串 用"" 括起来表示 sql ‘’表示
他们 之间用&连接起来
str1="select * from yuangongxinxi where 部门='"&Text1.Text &"' and 性别='女'
注意vb里不可以使用str 做变量名
那是保留字

vb:
str = "select * from yuangongxinxi where 部门=" & Text1.Text &"and 性别='女'

str = "select * from yuangongxinxi where 部门="Text1.Text"and 性别='女' "