首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

与此同时提交多条记录,实现不了,求帮助

2013-01-06 
同时提交多条记录,实现不了,求帮助本帖最后由 jvxie 于 2012-12-16 14:32:08 编辑!--#include fileCONN

同时提交多条记录,实现不了,求帮助
本帖最后由 jvxie 于 2012-12-16 14:32:08 编辑

<!--#include file="CONN.ASP"-->
<html>
<title>奖惩记录登记...</title>
<body>

<script>
function btn_ck_bh_Click()
{
var cx = document.form1.cxsj.value;
form1.action ="Bmxt_admin_modi_jiangcheng.asp?cx="+cx;
}
</script> 

<table width="100%" align="center" border="0" cellspacing="0" bgcolor="#E1F4EE" bordercolorlight="#4DA6FF" bordercolordark="#ECF5FF"  style="word-break:break-all"> 
<tr> 
<td width="100%" align="center" valign="middle" > <br><font size="2" color="#6A6A6A"><b>
<form method="POST" name="form1" action=Bmxt_Admin_Info.asp>请输入查询关键词:&nbsp;<input type="text" name="cxsj" size="25">&nbsp;<input type="submit" value="查询" name="B1" LANGUAGE="javascript" onClick="btn_ck_bh_Click()"> <input type="reset" value="重写" name="B2"> </form></b></font>
</td> 
</tr> 
</table> 



<form method="post" action="index_edit_jiangcheng.asp?action=edit&id=<%=id%>">

<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border">
<tr>

<td height="25" width="5%"><b>班级</b></td>
        <td width="5%"><b>学号</b></td>
<td width="5%"><b>姓名</b></td>
<td width="5%"><b>性别</b></td>
<td width="6%"><b>本人手机</b></td>
        <td width="5%"><b>政治面貌</b></td>
</tr>
 
<% 
'数据库查询 
'获得搜索内容 
cx = request("cx") 
dim pageCount 
'把page转换成整数 
page = cint(request("page")) 
set conn=server.createobject("adodb.connection")' 
set rs=server.createobject("adodb.recordset") 
conn.open "DBQ=" & server.mappath("MDB/sztt0805designbylbm.asa") & ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};" 

' 获取产品的名字记录集(从 news表中) 
if cx <> "" then 
sql = "SELECT * from bmxt where T1 like '%"&cx&"%' or T2 like '%"&cx&"%'  order by T4" 
else 
sql ="select * from bmxt  order by T4 " 
end if 
rs.open sql,conn,3,3 
'如果没有数据记录 
if rs.bof then 
errmsg=errmsg+"<br>"+"<li>"+keyword+"没有记录,换个关键词试试^^!!" 
response.write errmsg 
response.end 
end if 

' 设置记录集在每页的总行数,也就是 PageSize属性 
RS.PageSize=25 
'把rs.pageCount转换成整数和page才能作比较 
pageCount = cint(rs.pageCount) 
' 设置当前的页号( AbsolutePage属性) 
if page = 0 then 
page =1 
end if 
RS.AbsolutePage = page 
x=1 
' 显示当前页中的所有记录( PageSize中设置的行数) 

WHILE NOT RS.EOF AND NumRows<RS.PageSize 
%> 


<tr align="center" class="tdbg" onMouseOver="this.style.background='#CBE0D8'" onMouseOut="this.style.background='#E1F4EE'">



        <td height="23" width="5%"><%=rs("T2")%></td><!--班级 -->
<td width="5%"><%=rs("t3")%></td><!--学号 -->
<td width="5%" align="left">&nbsp;<%=rs("t4")%></td><!--姓名 -->
        <td width="5%"><%=rs("t5")%></td><!--性别 -->
        <td width="6%"><input type="title" name="T7" style="width:150px;height:30px;padding-top:8px;" value="<%=rs("T7")%>"></td><!--本人手机 -->
        <td width="5%"><input type="title" name="T13" style="width:150px;height:30px;padding-top:8px;" value="<%=rs("T13")%>"></td><!--政治面貌 -->
    </tr>
    
<%
RS.MoveNext 
NumRows=NumRows+1 
WEND
%> 

</table>

<br>
<table cellpadding="2" cellspacing="1" border="0" width="100%" class="border" align="center" id="table1">
<tr align="right">
<td width="105%" align="center" cellpadding="2" cellspacing="1" border="1"  class="topbg"> 
<p align="center"><font size="2" color="#990000">您正在查询的关键词:《&nbsp;<%=cx%>&nbsp;》</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT color=#333333>查询到&nbsp;<%=rs.recordcount%>&nbsp;条记录,每页25条,共&nbsp;<%=PageCount%>&nbsp;页&nbsp;★&nbsp;<font color="#FF3399">本页第&nbsp;<%=page%>&nbsp;页</font>&nbsp;★&nbsp; 
<%if page=1 then%>首页<%end if%> 
<%if page>1 then%> 
<A HREF="Bmxt_admin_modi_jiangcheng.asp?page=1&cx=<%=cx%>"> 首页</A> 
<%end if%>&nbsp; 
<%if page>1 then%><A HREF="Bmxt_admin_modi_jiangcheng.asp?page=<%=page-1%>&cx=<%=cx%>"><%end if%>上一页</a> 
<% 
dim pagewhere 
dim p 
p = 1 
'把pagewhere转换成整数 
'pagewhere = cint(request("pagewhere")) 
pagewhere = pageCount 
if pagewhere>0 then 
for p=1 to pagewhere 
if p <> page then%> 
<A HREF="Bmxt_admin_modi_jiangcheng.asp?page=<%=p%>&cx=<%=cx%>"><%=p%></a> 
<%end if 
if p =page then%> 
<%=p%> 
<% end if 
next 
end if%> 
<%if page < PageCount then%> 
<A HREF="Bmxt_admin_modi_jiangcheng.asp?page=<%=page+1%>&cx=<%=cx%>"> 
<%end if %>下一页</A>&nbsp; 
<%if page=PageCount then%>尾页 
<%end if%> 
<%if page<PageCount then%> 
<A HREF="Bmxt_admin_modi_jiangcheng.asp?page=<%=PageCount%>&cx=<%=cx%>"> 尾页</A> 
<%end if%> 
</p></FONT></td> </tr>
</table>

<% 
rs.close 
Set rs=nothing 
conn.close 
set conn=nothing 
%>


</td>
</tr>
</table>   
    
 


<table align="center">
<tr>
<td align="center">
<input style="BORDER-RIGHT: #cccccc 1px groove; FONT-WEIGHT: normal; FONT-SIZE: 9pt; LINE-HEIGHT: normal; BORDER-BOTTOM: #cccccc 1px groove; FONT-STYLE: normal; HEIGHT: 20px; BACKGROUND-COLOR: #eeeeee; FONT-VARIANT: normal" type="submit" value="修改资料!" name="submit">
</td></tr>
</table>   
</body>
</html>






调用index_edit_jiangcheng.asp

<!--#include file="conn.asp"-->
<% 
id=request("id")
%>
<%
if request("action") = "edit" then    'if id="200404082326201004082326" then
id=request("id") 
'img=request("img")
ok=request("ok")
t1=request("t1")
t2=request("t2")
t3=request("t3")
t4=request("t4")
t5=request("t5")
t6=request("t6")
t7=request("t7")
t8=request("t8")
t9=request("t9")
t10=request("t10")
t11=request("t11")
t12=request("t12")
t13=request("t13")
t14=request("t14")
t15=request("t15")
t16=request("t16")
t17=request("t17")
t18=request("t18")
t19=request("t19")
t20=request("t20")
t21=request("t21")
t22=request("t22")
t23=request("t23")
t24=request("t24")
t25=request("t25")
t26=request("t26")
t27=request("t27")
t28=request("t28")
t29=request("t29")
t30=request("t30")
set rs=server.createobject("adodb.recordset")
sql="select * from bmxt where id="&id
rs.open sql,conn,1,3
for i=1 to 2
'rs("img")=img
rs("ok")=ok
rs("t1")=t1
rs("t2")=t2
rs("t3")=t3
rs("t4")=t4
rs("t5")=t5
rs("t6")=t6
rs("t7")=t7
rs("t8")=t8
rs("t9")=t9
rs("t10")=t10
rs("t11")=t11
rs("t12")=t12
rs("t13")=t13
rs("t14")=t14
rs("t15")=t15
rs("t16")=t16
rs("t17")=t17
rs("t18")=t18
rs("t19")=t19
rs("t20")=t20
rs("t21")=t21
rs("t22")=t22
rs("t23")=t23
rs("t24")=t24
rs("t25")=t25
rs("t26")=t26
rs("t27")=t27
rs("t28")=t28
rs("t29")=t29
rs("t30")=t30
rs.update
rs.close
set rs=nothing
next
conn.close  
set conn=nothing

response.write "<script language='javascript'>" & chr(13)
response.write "alert('信息修改成功!');" & Chr(13)
response.write "window.document.location.href='Bmxt_admin_modi_jiangcheng.asp';"&Chr(13)
response.write "</script>" & Chr(13)
Response.End
else 
response.write "<script language='javascript'>" & chr(13)
response.write "alert('你提交的参数有误!点击确定返回重新输入!');" & Chr(13)
response.write "window.document.location.href='Bmxt_admin_modi_jiangcheng.asp';"&Chr(13)
response.write "</script>" & Chr(13)
Response.End
end if
%>

[解决办法]
name属性相同的表单提交后会变成数组,以你的为例接收的时候可以这样:

for i = 0 to requery.querystring("t7").count
rs(i) = requery.querystring("t7")(i)
next

但是从你的代码上看,错误很多,接收页面中缺少很多东西,比如提交页的数据是从第几个开始到第几个结束,还有,提交包含很多个记录,接收却只有一个等等,错误很多,建议你先成功的修改一条记录,然后再该为多条记录。

热点排行