注册 登录
编程论坛 ASP技术论坛

asp中删除记录的问题

xzlixun 发布于 2007-05-14 13:24, 757 次点击

这个是删除文件:
<!--#include file="conn.asp"-->
<%
set rs=server.CreateObject("adodb.recordset")
rs.open "delete * from stuinfo where 学号='"&a&"'"

rs.delete
rs.close
asconn.close
set asconn=nothing
response.redirect "shanchuchenggong.asp"
%>
这个是conn.asp:
<%
dim asconn
set asconn=server.createobject("adodb.connection")
asconn.open = "provider=SQLOLEDB.1;data source=LIXUN;"&_
"initial catalog=DB;user id=sa;password=sa;"
function encodestr(str)
str=trim(str)
str=replace(str,"<","&lt;")
str=replace(str,">","&gt;")
str=replace(str,"""","'")
str=replace(str,vbCrLf&vbCrlf,"</p><p>")
str=replace(str,vbCrLf,"<br>")
encodestr=replace(str," ","")
end function
function cutstr(tempstr,tempwid)
if len(tempstr)>tempwid then
cutstr=left(tempstr,tempwid)&"..."
else
cutstr=tempstr
end if
end function '限制新闻标题的显示字数的函数,后面以...显示

function astext(vstrin) '字符编码
dim i,strreturn
strreturn = ""
for i = 1 to len(vstrin)
thischr = mid(vstrin,i,1)
if abs(asc(thischr)) < &hff then
strreturn = strreturn & thischr
else
innercode = asc(thischr)
if innercode < 0 then
innercode = innercode + &h10000
end if
hight8 = (innercode and &hff00)\ &hff
low8 = innercode and &hff
strreturn = strreturn & "%" & hex(hight8) & "%" & hex(low8)
end if
next
astext = strreturn
end function
%>


错误类型:
ADODB.Recordset (0x800A0E7D)
连接无法用于执行此操作。在此上下文中它可能已被关闭或无效。
/bs/shanchu1.asp, 第 4 行


浏览器类型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)

网页:
POST 42 ??? /bs/shanchu1.asp

POST Data:
textfield=%C0%EE%D1%AB&Submit=%C9%BE%B3%FD

时间:
2007年5月14日, 13:21:14


详细信息:
Microsoft 支持
老师在催着交作业,请各位帮我看看,错误出在哪里?谢谢!

3 回复
#2
阳光白雪2007-05-14 13:34

<%
set rs=server.CreateObject("adodb.recordset")
rs.open "delete * from stuinfo where 学号='"&a&"'"
rs.delete
rs.close
asconn.close
set asconn=nothing
response.redirect "shanchuchenggong.asp"
%>
改成:
<%
asconn.Execute("delete * from stuinfo where 学号='"&a&"'")
asconn.close
set asconn=nothing
response.redirect "shanchuchenggong.asp"
%>
这样简单

#3
cyc3082007-05-14 14:41
楼上正解
#4
xiaobai405102007-11-16 09:58
我以前也碰到过,你可以把asconn.close去掉试试看
<%
set rs=server.CreateObject("adodb.recordset")
rs.open "delete * from stuinfo where 学号='"&a&"'"

rs.delete
rs.close
asconn.close
set asconn=nothing
response.redirect "shanchuchenggong.asp"
%>

1