中国移动领取免费流量:ASP移动数据记录问题,求大虾帮忙修改下!

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/06 04:02:09
<%
Dim reQ_strCmds
reQ_strCmds =Request("Cmds")

If reQ_strCmds ="up" or reQ_strCmds ="down" Then Call MoveRec(reQ_strCmds)

Sub MoveRec(paR_strCmds)

Dim reQ_intID, reQ_intCID, intMove
reQ_intID =Request("ID")
reQ_intCID =Request("CID")
Set Rs =Conn.Execute("Select Move From [Product] where ID ="& reQ_intID)
intMove =Rs("Move")
Set Rs =Nothing

If paR_strCmds ="up" Then
Set Rs =Conn.Execute("Select Top 1 ID, Move From [Product] where typeid ="& reQ_intCID &" and Move <"& intMove)
If Not Rs.Eof Then
Conn.Execute("Update [Product] Set Move ="& Rs("Move") &" where ID ="& reQ_intID)
Conn.Execute("Update [Product] Set Move ="& intMove &" where ID ="&Rs("ID"))
End If
Set Rs =Nothing
Else
Set Rs =Conn.Execute("Select Top 1 ID, Move From [Product] where typeid ="& reQ_intCID &" and Move >"& intMove)
If Not Rs.Eof Then
Conn.Execute("Update [Product] Set Move ="& Rs("Move") &" where ID ="& reQ_intID)
Conn.Execute("Update [Product] Set Move ="& intMove &" where ID ="&Rs("ID"))
End If
Set Rs =Nothing
End If
Set Rs =Nothing
Conn.Close
Set Conn =Nothing
Response.Redirect("product_list.asp?id="& reQ_intCID)
End Sub

%>
在PRODUCT表里存在move字段。TYPEID是分类字段,ID是自动编号,
该代码是处在PRODUCT_list.asp里的,另外读取数据记录的排序是move asc,id desc. 目前功能欠佳。比如有三条记录,每一条记录的后面都有一个上移下移按钮的,具体问题就是,如果你点第一条的下移,那第一条就会跳到第三条的位置了,而不是第二条,而第三条的上移也是一样的,就会直接移到第一条的位置,请那位大虾帮忙修改下吧! 上次有人回复我说这个功能ASP不能实现,但现在确实实现了。。

绝对能实现
if If paR_strCmds ="down" Then
str="Select Top 1 ID, Move From [Product] where typeid >"& reQ_intCID
else
str="Select Top 1 ID, Move From [Product] where typeid <"& reQ_intCID & "order by ID"

我估计你能看懂我的意思吧 连接数据库我就不写了

注意:提交的reQ_intCID是上一个数据集的typeid

建议你按照我的思路改动

向上的时候 选择大于插入点move的top 1的时候用move的升序

向下的时候 选择小于插入点move的top 1的时候用move的降序

然后再执行相应的交换move值的操作。