高手都来瞧瞧,解决了立马给分。
我写了一个更新程序,先将数据库中的信息导出到表单显示出来,然后更新提交。显示程序如下:
<%
Dim Conn
Dim ConnStr
dim rs
dim str
Set Conn = Server.CreateObject( "ADODB.Connection ")
ConnStr = "DRIVER={SQL Server};SERVER=szzxlxf;UID=sa;PWD=sa;Database=vote "
Conn.Open ConnStr
set rs=conn.execute( "select * from username ")
do while not rs.eof
response.write " <form name=tform action=a.asp method=post> "
response.write " <input type=text name=id value= "&rs( "id ")& "> "
response.write " <input type=text name=sname value= "&rs( "sname ")& "> "
response.write " <input type=text name=studyl value= "&rs( "studyl ")& "> "
response.write " <br/> "
rs.movenext
loop
response.write " <input type=submit name=submit value=提交> "
%>
<%
response.write " </form> "
%>
更新程序如下:
<%
Dim Conn
Dim ConnStr
dim rs
dim str
dim studyl
dim strquery
dim id
Set Conn = Server.CreateObject( "ADODB.Connection ")
ConnStr = "DRIVER={SQL Server};SERVER=szzxlxf;UID=sa;PWD=sa;Database=vote "
Conn.Open ConnStr
set rs=server.createobject( "adodb.recordset ")
str= "select * from username "
rs.open str,conn,3,2
rs.movefirst
while not rs.eof
studyl=trim(request( "studyl "))
strQuery = " update username set studyl= ' "&studyl& " ' "
rs.movenext
Conn.execute(strQuery)
wend
%>
可为什么每次更新时在表单输入studyl的值时比如第一个studyl表单输入50,第二个输入60可显示时出现50,60两个表单的值是一样的都是以50,60出现,是否是循环语句出了问题,高手指点
------解决方案--------------------哦,我知道了.生成的表单:
<form ....>
<%
'这里循环
response.write " <input type=text name=id value= "&rs( "id ")& "> "
response.write " <input type=text name=sname value= "&rs( "sname ")& "> "
response.write " <input type=text name=studyl value= "&rs( "studyl ")& "> "
%>
<input type= "submit " />
</form>
处理:
<%
id= trim(request.form( "id "))
sname= trim(request.form( "sname "))
studyl= trim(request.form( "studyl "))
if id <> " " then
arrID = split(id, ", ")
arrstudyl = split(studyl, ", &qu