rs.AddNew增加记录的位置怎么乱跳?

zhangqihong 2000-06-05 11:42:00
各位大虾:
我编的ASP程序如下,可老是不能在最后加上新纪录!请各位指教,多谢!
<html>
<body bgcolor=#DDDDDD>
<%
const PageSize=5
const adOpenDynamic=2
const adLockPessimistic=2
const adCmdText=1
const adUseClient=3
const adFilterNone=0

Session("UserBM")="000001"
Session("strSQL")="select * from 书架"
' where UserID="&Session("UserBM")&"'"

connStr="driver={sql server}; server=(local); UID=sa; PWD=; UserID=sa; Password=; database=秘书"

set Session("rs")=Server.CreateObject("ADODB.Recordset")
Session("rs").CursorLocation=adUseClient
Session("rs").MaxRecords=0
Session("rs").Open Session("strSQL"),connstr,adOpenDynamic,adLockPessimistic,adCmdText
Session("rs").PageSize=PageSize
Session("rs").Filter=adFilterNone

Response.Write "<form action='addBook2.asp' method=POST name=form1>"
Response.Write "<table border=2 align=center bordercolor=#AAAAAA cellspacing=0 bgcolor=#eeffff style='font:9pt; padding=0'>"
Response.Write "<tr color=blue style='color:red'>"
Response.Write "<td>顺序</td><td>类别</td><td>书名</td><td>出版社</td><td>价格</td><td>购买日期</td>"
Response.Write "</tr>"

Session("rs").MoveLast
for j=1 to Session("rs").PageSize-1
while Session("rs")("UserID").Value <> Session("UserBM")
Session("rs").MovePrevious
if Session("rs").BOF Then
Session("rs").MoveNext
exit for
end if
wend
Session("rs").MovePrevious
if Session("rs").BOF Then
Session("rs").MoveNext
exit for
end if
Next
Session("rs").MoveNext
' Session("rs").Move -3,0

do while NOT Session("rs").EOF
while Session("rs")("UserID").Value <> Session("UserBM")
Session("rs").MoveNext
if Session("rs").EOF Then
Session("rs").MovePrevious
exit do
end if
wend

Session("End")=Session("rs").AbsolutePosition
Response.Write "<tr>"
Response.Write "<td>"&Session("rs").AbsolutePosition&"</td>"

for i=1 to Session("rs").Fields.count-1
Response.Write "<td>"&Session("rs")(I).Value&"</td>"
next
Response.Write "</tr>"
Session("rs").MoveNext
loop
Response.Write "<tr><td>"&Session("End")+1&"</td>"
Response.Write "<td><input id=LB name=BKLB style='height:12pt; width:25px'></td>"
Response.Write "<td><input id=MC name=BKMC style='height:12pt; width:350px'></td>"
Response.Write "<td><input id=CB name=BKCB style='height:12pt; width:35px'></td>"
Response.Write "<td><input id=JG name=BKJG style='height:12pt; width:35px'></td>"
Response.Write "<td><input id=RQ name=BKRQ style='height:12pt; width:50px'></td></tr>"
Response.Write "</table>"
Response.Write "<div align=center style='maginTop:10px'><input id=addRec name=submit1 type=submit value=确定 style='font:9pt; color:blue; height:16pt'>"
Response.Write "<input id=clearRec name=reset1 type=reset style='font:9pt; height:16pt; color:blue' value=清除></div>"
Response.Write "</form>"
%>
</body>
</html>

addbook2.asp源程序:
<html>
<%
'Session("rs").MoveLast

Session("rs").AddNew
Session("rs")("UserID").Value=Session("UserBM")
Session("rs")("BookLB").Value=CInt(Request.Form("BKLB"))
Session("rs")("BookMC").Value=Request.Form("BKMC")
Session("rs")("BookCB").Value=CInt(Request.Form("BKCB"))
Session("rs")("BookJG").Value=CSng(Request.Form("BKJG"))
Session("rs")("BookRQ").Value=Request.Form("BKRQ")
Session("rs").Update

Session("rs").Close
set Session("rs")=nothing
%>
<!--#include file="addBook.asp"-->
</html>
...全文
146 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zigzag 2000-07-06
  • 打赏
  • 举报
回复
不要将connection对象保存在session中,尽量不要直接引用session变量。
smallxiong 2000-06-05
  • 打赏
  • 举报
回复
先说说你是说什么在乱跳,是纪录指针吗?
zdg 2000-06-05
  • 打赏
  • 举报
回复
直接使用Insert Into, 不要使用rs.AddNew

28,390

社区成员

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

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