asp 中access 查询语句错误!!!!!

来源:百度知道 编辑:UC知道 时间:2024/05/14 14:53:29
Microsoft VBScript 编译器错误 错误 '800a0401'

语句未结束

/staticFunc.asp,行 287

strSQL="select * from DateStatic where dateid=datepart("y","now()") and userID='" & userid & " '
strSQL="select * from DateStatic where dateid=datepart("y","now()") and userID=" & userid & " "
服务器: 消息 170,级别 15,状态 1,行 1
第 1 行: '=' 附近有语法错误。

改为这样看看行不:
dim Dsql
Dsql=datepart("y",now())
strSQL="select * from DateStatic where dateid="&Dsql&" and userID='"&userid&"'"
你的错误是字符串连接不对...
[附]
其中datepart(单位,时间) 为时间函数
单位:
"yyyy" 年,如2007
"m" 月
"d" 月中的哪一天(从 1 到 31)
"ww" 年中的哪一周(从 1 到 53)
"q" 季度
"y" 年中的哪一天(从 1 到 366)
"w" 星期几(从 1 到 7)
"h" 小时
"n" 分钟
"s" 秒钟.

无语
strSQL="select * from DateStatic where dateid=datepart("y","now()") and userID='" & userid & " '"

改为
strSQL="select * from DateStatic where dateid=datepart("y","now()") and userID=" & userid & " "
或者
strSQL="select * from DateStatic where dateid=datepart("y","now()") and userID='" & userid & " &#