sqlstr="update 成绩单 set id="& 0 & " where id=" & recordID '作临时处理,处理移动后修改到新位置就是了,否则会更新失败
objConn.Execute(sqlstr)
if offset >0 then '下移
sqlstr="update 成绩单 set id=id-1 where id > " & recordID & "and id<=" & newRecordID
else
sqlstr="update 成绩单 set id=id+1 where id <" & recordID & "and id>=" & newRecordID
end if
objConn.Execute(sqlstr)
sqlstr="update 成绩单 set id="& newRecordID & " where id=0" '把临时处理处理后的目标记录移到新位置
objConn.Execute(sqlstr)
end if
end if
sqlstr="select * from 成绩单 order by id asc"
set rs=objConn.execute(sqlstr)
%>
<table width="90%" border="1" cellpadding="2" cellspacing="1">
<tr bgcolor="#999999">
<th scope="col">1</th>
<th scope="col">2</th>
<th scope="col">3</th>
<th scope="col">4</th>
<th scope="col">5</th>
<th scope="col">6</th>
<th scope="col"> </th>
</tr>
<%
Dim theMsg( )
ReDim theMsg( 1500 ) ' 我随便定的一个大小
dim count2=-1
do where not rs.eof
count2=count2+1
If count2> UBound( theMsg) Then
ReDim Preserve theMsg( count2+ 99 )
End If
' 放到数组里
theMsg(count2) = Rs("AAA")
Rs.movenext
loop
ReDim Preserve theFiles(count2)
Count1=Ubound(theMsg)
For i = Count1 TO 0 Step -1
minmax = theMsg( 0 )
minmaxSlot = 0
For j = 1 To i
mark = (strComp( theFiles(j), minmax, vbTextCompare ) > 0)
If mark Then
minmax = theMsg( j )
minmaxSlot = j
End If
Next
Next
Msg=Join(theMsg,"@@@")
然后输出.
在这里关键是vbTextCompare 这个东西就是按字母排序了
Access不支持between吧.
-------------------------------------------------------------------------
id=request("原来的位置id")
offset=request("后移步数")
if offset >0 then
sqlstr="update tableName set id=id+1 where id > " & id-1 & "and id<=" & id+offset
else
sqlstr="update tableName set id=id-1 where id <" & id-1 & "and id>=" & id+offset
end if
conn.execute(sqlstr)
sqlstr="update tableName set id="& id+offset & "where id=" &id