高手看看我这段代码哪处错了?

Snakesnoop 2006-02-23 10:02:45
1楼 高手看看我这段代码哪处错了?

51 <%
52 StrConn = " Provider=SQLOLEDB.1;Persist Security InFso=true;Data Source='snake';Initial Catalog='snake';User ID='sa';Password='000111';CONNect Timeout=30 "
53 dim rs2,rs3,Strhtml,StrKB
54 StrKB = " select top 3 * from users where u_sex=female "
55 set rs2 = Conn.Execute(StrKB)
56 Strhtml=rs2("name")
57 while not rs2.eof
58 response.write(rs2("name"))
59 response.write("<br>")
60 rs2.movenext
61 wend
62 rs2.close
63 set rs2 = nothing
64 %>



提示

Microsoft VBScript 运行时错误 error '800a01a8'

缺少对象: ''

/index-2.asp, line 55

...全文
112 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
aylian 2006-02-23
  • 打赏
  • 举报
回复
rs2.open StrKB,Conn,1,1
Strhtml=rs2("name")*******此句读不出东西,因为记录集指针尚未移动
while not rs2.eof
response.write(rs2("name"))
response.write("<br>")
rs2.movenext
wend
rs2.close
set rs2 = nothing
Snakesnoop 2006-02-23
  • 打赏
  • 举报
回复
谢谢高手指点!!
tigerwen01 2006-02-23
  • 打赏
  • 举报
回复
对象rs2和Conn还没有创建。
<%
dim rs2,rs3,Strhtml,StrKB
Set Conn=Server.CreateObject("adodb.connection")
StrConn = " Provider=SQLOLEDB.1;Persist Security InFso=true;Data Source='snake';Initial Catalog='snake';User ID='sa';Password='000111';CONNect Timeout=30 "
Conn.open StrConn
Set rs2=Server.CreateObject("adodb.recordset")

StrKB = " select top 3 * from users where u_sex=female "
'set rs2 = Conn.Execute(StrKB)
rs2.open StrKB,Conn,1,1
Strhtml=rs2("name")
while not rs2.eof
response.write(rs2("name"))
response.write("<br>")
rs2.movenext
wend
rs2.close
set rs2 = nothing
%>
meizz 2006-02-23
  • 打赏
  • 举报
回复
StrKB = " select top 3 * from users where u_sex='female' " 'u_sex数据是字符型的吧
tokilcoom 2006-02-23
  • 打赏
  • 举报
回复
记录集没定义?
mgzhenhong 2006-02-23
  • 打赏
  • 举报
回复
(至少)我发现了两个错误
1. Conn没有Open
2. StrKB = " select top 3 * from users where u_sex=female "应该为
StrKB = "select top 3 * from users where u_sex='female'"

28,391

社区成员

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

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