'80040e14' 错误 知位帮忙看一下!谢谢

plpy 2003-11-18 07:45:45
Microsoft OLE DB Provider for SQL Server 错误 '80040e14'

在关键字 'Key' 附近有语法错误。

/article/Inc/syscode.asp,行907

代码如下:


sub ShowCorrelative(ArticleNum,TitleLen)
dim rsCorrelative,sqlCorrelative
dim strKey,arrKey,i
if ArticleNum>0 and ArticleNum<=100 then
sqlCorrelative="select top " & ArticleNum
else
sqlCorrelative="Select Top 5 "
end if
response.Flush()
strKey=rs("Key")

if instr(strkey," ")>1 then
arrKey=split(strKey," ")
strKey="((Key like '%" & arrKey(0) & " %')"
for i=1 to ubound(arrKey)
strKey=strKey & " or (Key like '%" & arrKey(i) & " %')"
next
strKey=strKey & ")"
else
strKey="(Key like '%" & strKey & " %')"

end if
sqlCorrelative=sqlCorrelative & " ArticleID,Title,Author,UpdateTime,Hits From Article Where Passed=1" & strKey & " and ArticleID<>" & ArticleID & " Order by ArticleID desc"
Set rsCorrelative= Server.CreateObject("ADODB.Recordset")
response.Flush()
rsCorrelative.open sqlCorrelative,conn,1,1 //此处为907行


if TitleLen<0 or TitleLen>255 then TitleLen=50
if rsCorrelative.bof and rsCorrelative.Eof then
response.write "没有相关文章"
else
do while not rsCorrelative.eof
response.write "<li><a href='ArticleShow.asp?ArticleID=" & rsCorrelative("ArticleID") & "' title='文章标题:" & rsCorrelative("Title") & vbcrlf & "作 者:" & rsCorrelative("Author") & vbcrlf & "更新时间:" & rsCorrelative("UpdateTime") & vbcrlf & "点击次数:" & rsCorrelative("Hits") & "'>" & gotTopic(rsCorrelative("Title"),TitleLen) & "</a>[<font color=red>" & rsCorrelative("hits") & "</font>]</li><br>"
rsCorrelative.movenext
loop
end if
rsCorrelative.close
set rsCorrelative=nothing
end sub

我用的是SQL SERVER 2000 数据库,在数据库中的字段是[key]这样定义的,为什么还会有错呢?
如果换做ACCCESS数据库运行正常!
...全文
87 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
plpy 2003-11-19
  • 打赏
  • 举报
回复
SQL 语句决对有问题 ,
问题是,在建表时用了 [Key]字段,

但是在SQL语句使用》[Key]为什么就出错呢

DeltaCat 2003-11-18
  • 打赏
  • 举报
回复
你先不要执行,而是

response.Write sqlCorrelative
response.end
看看 SQL 语句有没有问题

lovelimei 2003-11-18
  • 打赏
  • 举报
回复
根据代码解析是:RS对象出错(引用了一个不存在的字段名)
plpy 2003-11-18
  • 打赏
  • 举报
回复
在语句写成[key],我试过了,还是提示错误如下:


ADODB.Recordset 错误 '800a0cc1'

项目在所需的名称或序数中未被发现。

/article/Inc/syscode.asp,行891


DeltaCat 2003-11-18
  • 打赏
  • 举报
回复
inelm 这么快!啊,你写的少 ^_^
DeltaCat 2003-11-18
  • 打赏
  • 举报
回复
KEY 在 SQL SERVER 里是保留字,不能直接使用的
DeltaCat 2003-11-18
  • 打赏
  • 举报
回复
if instr(strkey," ")>1 then
arrKey=split(strKey," ")
strKey="(([Key] like '%" & arrKey(0) & " %')"
for i=1 to ubound(arrKey)
strKey=strKey & " or ([Key] like '%" & arrKey(i) & " %')"
next
strKey=strKey & ")"
else
strKey="([Key] like '%" & strKey & " %')"

end if
nchen123 2003-11-18
  • 打赏
  • 举报
回复
所有 key 改成 [key]
eduxh 2003-11-18
  • 打赏
  • 举报
回复
少了and/or/not
eduxh 2003-11-18
  • 打赏
  • 举报
回复
sqlCorrelative=sqlCorrelative & " ArticleID,Title,Author,UpdateTime,Hits From Article Where Passed=1 and " & strKey & " and ArticleID<>" & ArticleID & " Order by ArticleID desc"

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧