语法错误 (操作符丢失) 在查询表达式 'password=' 中

来源:百度知道 编辑:UC知道 时间:2024/06/10 14:57:40
Sub check

dim names,password
names=Trim(Request.Form("names"))
password=Trim(Request.Form("password"))

if isnumeric(id) then
if Len(names) > 0 and Len(password) > 0 then
connopen
dim sql
sql = "select * from users WHERE name='"& names &"'And password='"& password &"'"
conn.Execute sql
connclose
response.Redirect("admin.asp")
Response.write("留言成功!")
else
response.Redirect("admin.asp")
end if
else
response.Redirect("admin.asp")
end if
End Sub

错误是
错误类型:
Microsoft JET Database Engine (0x80040E14)
语法错误 (操作符丢失) 在查询表达式 'password=' 中。
/ddd/admin.asp, 第 13 行
更改一下

connopen '这种写法确认是正确的吗?数据库连接的写法是什麽呢
dim sql
sql = "select * from users WHERE name='"& names &"'And password='"& password &"'"
conn.Execute sql
connclose '这种写法确认是否写正确了.正确应为conn.close

password变量传递问题吧

sql = "select * from users WHERE name='"& names &"'And password='"& password &"'"
这个SQL语句是不是少了个空格?
sql = "select * from users WHERE name='"& names &"' And password='"& password &"'"
如果不是,那就要给password加个判断,password空值时会出这个错误。