日期:2014-05-17  浏览次数:20948 次

我在代码末尾加上rs.close ,关闭数据集,就报错~~~
<!--#include   file= "admin_conndb.asp "   -->
<%  
teachno1=request.form( "teachno ")
teachname=request.form( "teachername ")
sex=request.form( "gender ")
teachtype1=request.form( "teachtype ")
birthday1=cdate(request.Form( "date "))
abouts1=request.form( "detail ")
set   rs=server.CreateObject( "ADODB.RecordSet ")
sqlstr= "insert   into     teachers(teachno,teachname,teachtype,sex,birthday,abouts)   values   ( "&teachno1& ", ' "&teachname& " ', ' "&teachtype1& " ', ' "&sex& " ', ' "&birthday1& " ', ' "&abouts1& " ') "
rs.open   sqlstr,conndb,3,2

set   rs=nothing
set   conndb=nothing
%>

<script   language   =   Javascript>
<!--
alert( "讲师添加成功! ");
window.location= "teacher.asp "
//-->
</script>

如题,加上rs.close就不行,不用关闭数据集么?
另外, "rs.open   sqlstr,conndb,3,2 "这句,这样写没什么问题吧?


------解决方案--------------------
对数据库操作的顺序
1 conn.open
2 rs.open
3 rs.close
set rs=nothing
4 conn.close
set conn
------解决方案--------------------
直接把
rs.open sqlstr,conndb,3,2

rs.close
set rs=nothing
set conndb=nothing

换掉 conndb.execute(sqlstr)好了

或者,因为是插入操作
sqlstr = "select * from teachers where 1=2 "
rs.open sqlstr ,3,3
rs.addnew
rs( "teachno ") = teachno1
...
rs.update
rs.close
conndb.close