关于ASP的错误类型:(0x80020009)发生意外问题
来源:百度知道 编辑:UC知道 时间:2024/05/27 20:50:54
我是个初学者.
option explicit
dim conn,connstr,db,rs
db="database/#TimesShop.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
conn.Open connstr
do while not rs.eof
dim shop,username,rs2
set shop=server.CreateObject("adodb.recordset")
shop.open "select username from [user] where userid="&rs"userid"),conn,1,1
username=trim(shop("username"))
shop.close
他总是提示:
错误类型:(0x80020009)发生意外。
/ebuy/admin/editorder.asp, 第 142 行
username=trim(shop("username"))
我是想从ACCESS中获得username的值,你给出的好象是从表单上的吧?
set shop=server.CreateObject("adodb.recordset")
这个不就是定义的记录了吗??
我用shop()赋值,是不是要用这中形式?
trim(shop.username)
日,小气的要死,1分都舍不得给.
正确的代码应该是这样的
====================================================
option explicit
dim conn,connstr,db,rs
db="database/#TimesShop.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
conn.Open connstr
rs.open "查询语句",conn,1,1 '在此打开你的rs的记录集下面才能循环,你看你上面什么都没有
dim shop,username,rs2
while not rs.eof and not rs.bof
set shop=server.CreateObject("adodb.recordset")
shop.open "select username from [user] where userid="&rs("userid"),conn,1,1
if not shop.eof and not shop.bof then'最好加上这句,这样就不会出现意外了,如果没有查到数据你在下面调用shop记录集的值,那必错不疑
username=trim(shop("username"))
end if
shop.close
wend '这里要结束你上面的while循环,好像你也没有,真惨
rs.close
=====================================