请教大侠!

yfyeah 2002-05-11 11:14:59
发生这样的错误应该怎么样改正呢?
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e14'

[Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失) 在查询表达式 'AND USERNAME='aa'' 中。

/QUserResult.asp,行124
...全文
5 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
ChinaOk 2002-05-11
if cbUserID = "on" then
Conditions = " USERID='" &txtUserID &"' "
HasChoose = 1
end if

if cbUserName = "on" then
Conditions = " USERNAME='" &txtUserName &"' "
if HasChoose = 0 then
HasChoose = 1
else
Conditions = " AND " &Conditions
end if
end if

他们之间少and啊。
回复
ChinaOk 2002-05-11

rst.Open sSQL,Conn,1,1
前加一个
response.write sSql
看看你生成的sql语句,就会发现你的错误了。
回复
yfyeah 2002-05-11
dim sDsn,sSQL
Set Conn = Server.CreateObject("ADODB.Connection")
sDsn = m_SystemDSN
Conn.Open sDsn

Set rst = Server.CreateObject("ADODB.Recordset")
rst.CursorLocation = 3
rst.CacheSize = 5

sSQL = "SELECT * FROM USERDATA "

dim HasChoose,Conditions
HasChoose = 0

if cbUserID = "on" then
Conditions = " USERID='" &txtUserID &"' "
HasChoose = 1
end if

if cbUserName = "on" then
Conditions = " USERNAME='" &txtUserName &"' "
if HasChoose = 0 then
HasChoose = 1
else
Conditions = " AND " &Conditions
end if
end if

if cbAccountDate = "on" then
Conditions = " OPENDATE >= CDate('" &beginTime &"') AND OPENDATE <= CDate('" &endTime &"') "
if HasChoose = 0 then
HasChoose = 1
else
Conditions = " AND " &Conditions
end if
end if

if HasChoose = 1 then
sSQL = sSQL &" WHERE " &Conditions
end if


rst.Open sSQL,Conn,1,1

if rst.EOF or rst.BOF then
response.write "<p align=center> 没有您所要找的记录! </p>"
response.write "<p align=center><A href=""javascript:history.back(1)"">返回</A></p>"
response.end
end if

回复
BrightEye 2002-05-11
楼上说的对.
回复
ChinaOk 2002-05-11
你的Sql语句错了。好像多了个'
代码帖了看看。
回复
超级大笨狼 2002-05-11
少了and
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2002-05-11 11:14
社区公告
暂无公告