SQL多条件查询语句..................

来源:百度知道 编辑:UC知道 时间:2024/09/22 05:28:17
Str = "select * from 用户表 where id='" & Text1.Text & "'" And "pass='" & Text2.Text & "'"
rs.Open Str, Con, adOpenKeyset, adLockPessimistic
Text3.Text = rs.Fields(0)
Text4.Text = rs.Fields(1)

上面的SQL语句有问题吗?
我运行老是说类型不对,我用的是Access数据库,ID和PASS字段都是文本类型的.

类型没问题,只是你的And写在了""之外。

Str = "select * from 用户表 where id='" & Text1.Text & "'" & "And pass='" & Text2.Text & "'"

Id为字符串用
Str = "select * from 用户表 where id='" & Text1.Text & "' and pass='" & Text2.Text & "'"
为整型用
Str = "select * from 用户表 where id=" & Text1.Text & " and pass='" & Text2.Text & "'"

本想进来挣个分,没想高手全答了。而且都是对的