我有一段代码可以实现添加记录功能,我仿照它改成另外一个文件,想实现修改记录,但总不起作用,不知道该修改哪里,添加功能页面代码如下:<%
Dim objDB,objRS,strSQL
Set objDB = Server.CreateObject("ADODB.Connection")
OpenDB objDB
Set objRS = Server.CreateObject("ADODB.Recordset")
if Request.Form("IsSubmit")<>"" Then
strSQL = "select * from t_TQuiz"
objRS.Open strSQL,objDB,1,3
objRS.AddNew()
objRS.Fields("Subject") = Request.Form("Subject")
objRS.Fields("Des") = Request.Form("Des")
objRS.Fields("SubCount") = Request.Form("SubCount")
objRS.Fields("MaxScore") = Request.Form("MaxScore")
objRS.Fields("AnswerDes") = Request.Form("AnswerDes")
objRS.Fields("TQType") = Request.Form("TQType")
objRS.Update()
objRS.Close()
objDB.Close()
Set objRS = Nothing
Set objDB = Nothing
End If
' objRS.Close()
%>
<Form action="" method="post" name="thisForm" onsubmit="return checkdata()">
<table width=760 border=0 align=center cellpadding="0" cellspacing="0" bgcolor="#EAEAEA">
<tr>
<td width=25%> </td>
<td width=75%> </td>
</tr>
<tr>
<td colspan=2 align=center><strong>添加试题内容</strong></td>
</tr>
<tr>
<td colspan=2 align=center> </td>
</tr>
<tr>
<td height=1 colspan=2 align=center bgcolor="#CCCCCC"></td>
</tr>
<tr>
<td height=1 colspan=2 align=center bgcolor="#FFFFFF"></td>
</tr>
<tr>
<td colspan=2 align=center> </td>
</tr>
<tr>
<td><div align="center">试题主题</div></td>
<td> <textarea name=Subject cols=80 rows=8></textarea>
</td>
</tr>
<tr>
<td><div align="center">试题期数</div></td>
<td> <Select name="TQType">
<option value="1" selected>第一期</option>
<option value="2">第二期</option>
<option value="3">第三期</option>
<option value="4">第四期</option>
<option value="5">第五期</option>
<option value="6">第六期</option>
<option value="7">第七期</option>
<option value="8">第八期</option>
</select> </td>
</tr>
<tr>
<td><div align="center">项目数量</div></td>
<td> <input name=SubCount size=3> </td>
</tr>
<tr>
<td><div align="center">最高分</div></td>
<td> <input name=MaxScore size=3> </td>
</tr>
<tr>
<td><div align="center">试题简单描述</div></td>
<td> <textarea name=Des cols=80 rows=8></textarea>
</td>
</tr>
<tr>
<td><div align="center">测试结果分析</div></td>
<td> <textarea name=AnswerDes cols=80 rows=8></textarea>
</td>
</tr>
<tr>
<td></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td></td>
<td><input name=submit type=submit value="添加试题"> <input type="button" name="Button" value="添加答案" onclick="window.location.href='addsubquestion.asp'">
<input type="button" name="Button2" value="问题管理" onclick="window.location.href='AllSubject.asp'">
<input type="button" name="Button2" value="答案管理" onclick="window.location.href='AllSubQuestion.asp'">
<input name="button" type=button onClick=window.close() value="关闭窗口"></td>
<td> </td>
</tr>
<tr>
<td></td>
<td> </td>
<td> </td>
</tr>
</table>
<input type=hidden name="IsSubmit" value="True">
</form>
Dim objDB,objRS,strSQL
Set objDB = Server.CreateObject("ADODB.Connection")
OpenDB objDB
Set objRS = Server.CreateObject("ADODB.Recordset")
if Request.Form("IsSubmit")<>"" Then
strSQL = "select * from t_TQuiz"
objRS.Open strSQL,objDB,1,3
objRS.AddNew()
objRS.Fields("Subject") = Request.Form("Subject")
objRS.Fields("Des") = Request.Form("Des")
objRS.Fields("SubCount") = Request.Form("SubCount")
objRS.Fields("MaxScore") = Request.Form("MaxScore")
objRS.Fields("AnswerDes") = Request.Form("AnswerDes")
objRS.Fields("TQType") = Request.Form("TQType")
objRS.Update()
objRS.Close()
objDB.Close()
Set objRS = Nothing
Set objDB = Nothing
End If
' objRS.Close()
%>
<Form action="" method="post" name="thisForm" onsubmit="return checkdata()">
<table width=760 border=0 align=center cellpadding="0" cellspacing="0" bgcolor="#EAEAEA">
<tr>
<td width=25%> </td>
<td width=75%> </td>
</tr>
<tr>
<td colspan=2 align=center><strong>添加试题内容</strong></td>
</tr>
<tr>
<td colspan=2 align=center> </td>
</tr>
<tr>
<td height=1 colspan=2 align=center bgcolor="#CCCCCC"></td>
</tr>
<tr>
<td height=1 colspan=2 align=center bgcolor="#FFFFFF"></td>
</tr>
<tr>
<td colspan=2 align=center> </td>
</tr>
<tr>
<td><div align="center">试题主题</div></td>
<td> <textarea name=Subject cols=80 rows=8></textarea>
</td>
</tr>
<tr>
<td><div align="center">试题期数</div></td>
<td> <Select name="TQType">
<option value="1" selected>第一期</option>
<option value="2">第二期</option>
<option value="3">第三期</option>
<option value="4">第四期</option>
<option value="5">第五期</option>
<option value="6">第六期</option>
<option value="7">第七期</option>
<option value="8">第八期</option>
</select> </td>
</tr>
<tr>
<td><div align="center">项目数量</div></td>
<td> <input name=SubCount size=3> </td>
</tr>
<tr>
<td><div align="center">最高分</div></td>
<td> <input name=MaxScore size=3> </td>
</tr>
<tr>
<td><div align="center">试题简单描述</div></td>
<td> <textarea name=Des cols=80 rows=8></textarea>
</td>
</tr>
<tr>
<td><div align="center">测试结果分析</div></td>
<td> <textarea name=AnswerDes cols=80 rows=8></textarea>
</td>
</tr>
<tr>
<td></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td></td>
<td><input name=submit type=submit value="添加试题"> <input type="button" name="Button" value="添加答案" onclick="window.location.href='addsubquestion.asp'">
<input type="button" name="Button2" value="问题管理" onclick="window.location.href='AllSubject.asp'">
<input type="button" name="Button2" value="答案管理" onclick="window.location.href='AllSubQuestion.asp'">
<input name="button" type=button onClick=window.close() value="关闭窗口"></td>
<td> </td>
</tr>
<tr>
<td></td>
<td> </td>
<td> </td>
</tr>
</table>
<input type=hidden name="IsSubmit" value="True">
</form>
<%
Dim objDB,objRS,strSQL,QID
QID = FixSQL(Request.QueryString("QID"))
Set objDB = Server.CreateObject("ADODB.Connection")
OpenDB objDB
Set objRS = Server.CreateObject("ADODB.Recordset")
strSQL = "Select * From t_TQuiz Where ID = " & QID
objRS.Open strSQL,objDB,1,3
' objRS.Close()
%>
<Form action="" method="post" name="thisForm" onsubmit="return checkdata()">
<table width=760 border=0 align=center cellpadding="0" cellspacing="0" bgcolor="#EAEAEA">
<tr>
<td width=25%> </td>
<td width=75%> </td>
</tr>
<tr>
<td colspan=2 align=center><strong>添加试题内容</strong></td>
</tr>
<tr>
<td colspan=2 align=center> </td>
</tr>
<tr>
<td height=1 colspan=2 align=center bgcolor="#CCCCCC"></td>
</tr>
<tr>
<td height=1 colspan=2 align=center bgcolor="#FFFFFF"></td>
</tr>
<tr>
<td colspan=2 align=center> </td>
</tr>
<tr>
<td><div align="center">试题主题</div></td>
<td> <textarea name=Subject cols=80 rows=8><%=objRS("Subject")%></textarea>
</td>
</tr>
<tr>
<td><div align="center">试题期数</div></td>
<td> <Select name="TQType">
<option value="<%=objRS("TQType")%>"><%if objRS("TQType")=1 then%>第一期<%end if%><%if objRS("TQType")=2 then%>第二期<%end if%><%if objRS("TQType")=3 then%>第三期<%end if%><%if objRS("TQType")=4 then%>第四期<%end if%><%if objRS("TQType")=5 then%>第五期<%end if%><%if objRS("TQType")=6 then%>第六期<%end if%><%if objRS("TQType")=7 then%>第七期<%end if%><%if objRS("TQType")=8 then%>第八期<%end if%></option>
<option value="1">第一期</option>
<option value="2">第二期</option>
<option value="3">第三期</option>
<option value="4">第四期</option>
<option value="5">第五期</option>
<option value="6">第六期</option>
<option value="7">第七期</option>
<option value="8">第八期</option>
</select> </td>
</tr>
<tr>
<td><div align="center">项目数量</div></td>
<td> <input name=SubCount size=3 value=<%=objRS("SubCount")%>> </td>
</tr>
<tr>
<td><div align="center">最高分</div></td>
<td> <input name=MaxScore size=3 value=<%=objRS("MaxScore")%>> </td>
</tr>
<tr>
<td><div align="center">试题简单描述</div></td>
<td> <textarea name=Des cols=80 rows=8><%=objRS("Des")%></textarea>
</td>
</tr>
<tr>
<td><div align="center">测试结果分析</div></td>
<td> <textarea name=AnswerDes cols=80 rows=8><%=objRS("AnswerDes")%></textarea>
</td>
</tr>
<tr>
<td></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td></td>
<td><input name=submit type=submit value="修改试题"> <input type="button" name="Button" value="添加答案" onclick="window.location.href='addsubquestion.asp'">
<input type="button" name="Button2" value="问题管理" onclick="window.location.href='AllSubject.asp'">
<input type="button" name="Button2" value="答案管理" onclick="window.location.href='AllSubQuestion.asp'">
<input name="button" type=button onClick=window.close() value="关闭窗口"></td>
<td> </td>
</tr>
<tr>
<td></td>
<td> </td>
<td> </td>
</tr>
</table>
<input type=hidden name="IsSubmit" value="True">
</form>
<%
Dim objDB1,objRS1,strSQL1
Set objDB1 = Server.CreateObject("ADODB.Connection")
OpenDB objDB1
Set objRS1 = Server.CreateObject("ADODB.Recordset")
if Request.Form("IsSubmit")<>"" Then
strSQL1 = "select * from t_TQuiz"
objRS1.Open strSQL1,objDB1,1,3
objRS1.addnew()
objRS1.Fields("Subject") = Request.Form("Subject")
objRS1.Fields("Des") = Request.Form("Des")
objRS1.Fields("SubCount") = Request.Form("SubCount")
objRS1.Fields("MaxScore") = Request.Form("MaxScore")
objRS1.Fields("AnswerDes") = Request.Form("AnswerDes")
objRS1.Fields("TQType") = Request.Form("TQType")
objRS1.Update()
objRS1.Close()
objDB1.Close()
Set objRS1 = Nothing
Set objDB1 = Nothing
End If
' objRS.Close()
%>
当然要确定修改哪条了,举个例子,sql="select * from t_TQuiz where 1=1" & "and yourcol=" & request("yourpara")
Dim objDB,objRS,strSQL,QID
QID = FixSQL(Request.QueryString("QID"))
Set objDB = Server.CreateObject("ADODB.Connection")
OpenDB objDB
Set objRS = Server.CreateObject("ADODB.Recordset")
strSQL = "Select * From t_TQuiz Where ID = " & QID
objRS.Open strSQL,objDB,1,3
' objRS.Close()
%>------------------------------------------------------
<%
Dim objDB,objRS,strSQL,QID
QID = FixSQL(Request.QueryString("QID"))
Set objDB = Server.CreateObject("ADODB.Connection")
OpenDB objDB
Set objRS = Server.CreateObject("ADODB.Recordset")
strSQL = "Select * From t_TQuiz Where ID = " & QID
objRS.Open strSQL,objDB,1,3
if objRS.recordcount>0 then
objRS.edit
objRS.Fields("Subject") = Request.Form("Subject")
objRS.Fields("Des") = Request.Form("Des")
objRS.Fields("SubCount") = Request.Form("SubCount")
objRS.Fields("MaxScore") = Request.Form("MaxScore")
objRS.Fields("AnswerDes") = Request.Form("AnswerDes")
objRS.Fields("TQType") = Request.Form("TQType")
objRS.Update()
endif
' objRS.Close()
%>
if Request.Form("IsSubmit")<>"" Then
strSQL1 = "select * from t_TQuiz"
objRS1.Open strSQL1,objDB1,1,3
objRS1.addnew()
objRS1.Fields("Subject") = Request.Form("Subject")
objRS1.Fields("Des") = Request.Form("Des")
objRS1.Fields("SubCount") = Request.Form("SubCount")
objRS1.Fields("MaxScore") = Request.Form("MaxScore")
objRS1.Fields("AnswerDes") = Request.Form("AnswerDes")
objRS1.Fields("TQType") = Request.Form("TQType")
objRS1.Update()
objRS1.Close()
objDB1.Close()
Set objRS1 = Nothing
Set objDB1 = Nothing
End If
' objRS.Close()
%>
改为:
if Request.Form("IsSubmit")<>"" Then
strSQL1 = "select * from t_TQuiz"
objRS1.Open strSQL1,objDB1,1,3
objRS1.edit
objRS1.Fields("Subject") = Request.Form("Subject")
objRS1.Fields("Des") = Request.Form("Des")
objRS1.Fields("SubCount") = Request.Form("SubCount")
objRS1.Fields("MaxScore") = Request.Form("MaxScore")
objRS1.Fields("AnswerDes") = Request.Form("AnswerDes")
objRS1.Fields("TQType") = Request.Form("TQType")
objRS1.Update()
objRS1.Close()
objDB1.Close()
Set objRS1 = Nothing
Set objDB1 = Nothing
End If
' objRS.Close()
%>
就是把addnew()改为了edit,可是出现错误:
Microsoft VBScript 运行时错误 错误 '800a01b6' 对象不支持此属性或方法: 'Edit' /manaclub/ModiSubject.asp,行143
这是怎么回事呢?
Microsoft VBScript 运行时错误 错误 '800a01b6' 对象不支持此属性或方法: 'edit' /manaclub/ModiSubject.asp,行143
我就是把:
<%
Dim objDB1,objRS1,strSQL1Set objDB1 = Server.CreateObject("ADODB.Connection")
OpenDB objDB1
Set objRS1 = Server.CreateObject("ADODB.Recordset")if Request.Form("IsSubmit")<>"" Then
strSQL1 = "select * from t_TQuiz"
objRS1.Open strSQL1,objDB1,1,3
objRS1.addnew()objRS1.Fields("Subject")=Request.Form("Subject")
objRS1.Fields("Des")=Request.Form("Des")
objRS1.Fields("SubCount")=Request.Form("SubCount")
objRS1.Fields("MaxScore")=Request.Form("MaxScore")
objRS1.Fields("AnswerDes")=Request.Form("AnswerDes")
objRS1.Fields("TQType")=Request.Form("TQType")
objRS1.Update()
objRS1.Close()
objDB1.Close()
Set objRS1 = Nothing
Set objDB1 = NothingEnd If
'objRS.Close()
%>
改为的:
<%
Dim objDB1,objRS1,strSQL1,QID1
QID1 = FixSQL(Request.QueryString("QID"))
Set objDB1 = Server.CreateObject("ADODB.Connection")
OpenDB objDB1
Set objRS1 = Server.CreateObject("ADODB.Recordset")strSQL1 = "Select * From t_TQuiz Where ID = " & QID
objRS1.Open strSQL1,objDB1,1,3
if objRS1.recordcount>0 then
objRS1.edit
objRS1.Fields("Subject")=Request.Form("Subject")
objRS1.Fields("Des")=Request.Form("Des")
objRS1.Fields("SubCount")=Request.Form("SubCount")
objRS1.Fields("MaxScore")=Request.Form("MaxScore")
objRS1.Fields("AnswerDes")=Request.Form("AnswerDes")
objRS1.Fields("TQType")=Request.Form("TQType")
objRS1.Update()
end if
'objRS.Close()
%>
Dim objDB1,objRS1,strSQL1,QID1
Set objDB1 = Server.CreateObject("ADODB.Connection")
OpenDB objDB1
Set objRS1 = Server.CreateObject("ADODB.Recordset")objRS1.Open = "Select * From t_TQuiz Where ID = "&request.QueryString("id"),strSQL1,objDB1,1,3 if objRS1.recordcount>0 then
objRS1.Fields("Subject")=Request.Form("Subject")
objRS1.Fields("Des")=Request.Form("Des")
objRS1.Fields("SubCount")=Request.Form("SubCount")
objRS1.Fields("MaxScore")=Request.Form("MaxScore")
objRS1.Fields("AnswerDes")=Request.Form("AnswerDes")
objRS1.Fields("TQType")=Request.Form("TQType")
objRS1.Update()
end if
'objRS.Close()
%>