100分!请问怎么样能更新用ASP显示的数据库的内容,在页面修改后,更新到数据库里面,注意有多条记录同时
---------------------------------------------------------------
这是完整的code拉,包含显示、修改:
1
2dim action
3action=Trim(Request.QueryString("action"))
4if action="" then
5action="display"
6end if
7'根据参数来决定执行那段子程序
8Select Case action
9case "display" call display
10Case "indexone" Call indexone
11Case "indextwo" Call indextwo
12End Select
13'无参数时的默认菜单排序页面
14Sub display
1<table border="0" width="400">
2<tr>
3<td align="center" valign="top" width="50%">
4<br/><br/>
5<form action="admin_menu_index.asp?action=indexone" method="post" name="indexone">
6<table align="center" bgcolor="```
7=BgColor1
8```" border="0" cellpadding="4" cellspacing="1" width="130">
9<tr>
10<td bgcolor="```
11=BgColor2
12```" class="w" colspan="2" height="25">一级菜单排序</td>
13</tr>
14<tr align="center" bgcolor="```
15=BgColor4
16```" height="25">
17<td width="65%">菜单</td>
18<td width="35%">序号</td>
19</tr>
dim sql
sql="Select distinct MenuA,IndexA From menu Order By IndexA"
adminrs.open sql,adminconn,1,1
If adminrs.EOF Then
1<tr "="" align="center" bgcolor="```
2=BgColor4
3```">
4<td width="65%">\--</td>
5<td width="35%">\--</td>
6</tr>
Else
While Not adminrs.EOF
1<tr "="" bgcolor="```
2=BgColor4
3```">
4<td width="65%">```
5=adminrs("MenuA")
6```<input ```"="" menua")="" name="MenuA" type="hidden" value="```
7=adminrs("/></td>
8<td align="center" width="35%"><input ```"="" indexa")="" maxlength="2" name="IndexA" size="2" type="text" value="```
9=adminrs("/></td>
10</tr>
adminrs.MoveNext
wend
End If
1<tr "="" bgcolor="```
2=BgColor4
3```">
4<td align="right" colspan="2" width="100%"><input type="submit" value="重新排序"/></td>
5</tr>
6</table>
7</form>
8</td>
9<td align="center" valign="top" width="50%">
10<br/>
adminrs.close
Set adminrstwo=Server.Createobject("adodb.recordset")
adminrstwo.open "Select MenuB,IndexB From menu Where NumB<>0 Order By IndexB",adminconn,1,1
1<br/>
2<form action="admin_menu_index.asp?action=indextwo" method="post" name="indextwo">
3<table align="center" bgcolor="```
4=BgColor1
5```" border="0" cellpadding="4" cellspacing="1" width="180">
6<tr>
7<td bgcolor="```
8=BgColor2
9```" class="w" colspan="2" height="25">二级菜单排序</td>
10</tr>
11<tr align="center" bgcolor="```
12=BgColor4
13```" height="25">
14<td width="65%">菜单</td>
15<td width="35%">序号</td>
16</tr>
If adminrstwo.EOF Then
1<tr "="" align="center" bgcolor="```
2=BgColor4
3```">
4<td width="65%">\--</td>
5<td width="35%">\--</td>
6</tr>
Else
While Not adminrstwo.EOF
1<tr "="" bgcolor="```
2=BgColor4
3```">
4<td width="65%">```
5=adminrstwo("MenuB")
6```<input ```"="" menub")="" name="MenuB" type="hidden" value="```
7=adminrstwo("/></td>
8<td align="center" width="35%"><input ```"="" indexb")="" maxlength="2" name="IndexB" size="2" type="text" value="```
9=adminrstwo("/></td>
10</tr>
adminrstwo.MoveNext
wend
End If
1<tr "="" bgcolor="```
2=BgColor4
3```">
4<td align="right" colspan="2" width="100%"><input type="submit" value="重新排序"/></td>
5</tr>
6</table>
7</form>
8</td>
9</tr>
10</table>
1
2adminrstwo.close
3End Sub
4
5'一级菜单重新排序子程序
6Sub indexone
7dim AID,AName,sql
8Call ChkBlank(request("IndexA"),"[序号]")
9AID=split(request("IndexA"),", ")
10AName=split(request("MenuA"),", ")
11
12for j=0 to ubound(AID)
13
14Call ChkBlank(AID(j),"[一级菜单序号"&j+1&"]")
15Call ChkBadWords(AID(j),"[一级菜单序号"&j+1&"]")
16
17sql="update menu set IndexA="&AID(j)&" where MenuA='"&AName(j)&"' "
18adminconn.execute sql
19next
20response.write "
```
```
```
```
<p>恭喜:一级菜单排序成功!</p>
```
```
```
"```
```End Sub
'二级菜单重新排序子程序
Sub indextwo
dim BID,BName,sql
BID=split(request("IndexB"),", ")
BName=split(request("MenuB"),", ")
for j=0 to ubound(BID)
Call ChkBlank(BID(j),"[二级菜单序号"&j+1&"]")
Call ChkBadWords(BID(j),"[二级菜单序号"&j+1&"]")
sql="update menu set IndexB="&BID(j)&" where MenuB='"&BName(j)&"' "
adminconn.execute sql
next
response.write "
1<p>恭喜:二级菜单排序成功!</p>
"
```
```End Sub
Set adminrstwo=Nothing
Set adminrs=Nothing
adminconn.Close
Set adminconn=Nothing
1<!--#include file="admin_foot.asp"-->