批量修改数据再问一次!

zxlh 2003-12-11 12:35:52
a:

<% while not rs.eof %>
<tr>
<td width="100" height="25"> <div align="center">
<input name="id" type="checkbox" id="id" value="<%=rs("id")%>" <%if rs("实际入库")<>"" then response.write "disabled"%>>
</div>
</td>
</tr>
<% rs.movenext%>
<%wend%>


b:
<%
Dim ID,II
ID=Request.Form("id")
II=Split(ID,",")
for i=0 to ubound(II)
sSQL ="update [j_superorder] set 实际入库='"&date()&"' where id="&II(i)
Conn.Execute(sSQL)
next

%>

我想在修改时多加1个字段。怎么加?
...全文
42 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
孟子E章 2003-12-11
  • 打赏
  • 举报
回复
先用
ALTER TABLE doc_exa ADD column_b VARCHAR(20) NULL

增加一个字段
zxlh 2003-12-11
  • 打赏
  • 举报
回复
我的想法:
a:
<% while not rs.eof %>
<tr>
<td width="115" height="25"> <div align="center">
<input name="bz" type="text" id="bz" value="<%=rs("包装件数")%>" size="12" class="input">
</div></td>
<td width="63" height="25"><div align="center">
<input name="tj" type="text" id="tj" value="<%=rs("商品体积")%>" size="12" class="input" >
</div></td>
<td height="25"> <div align="center"><%=rs("实际入库")%></div></td>
<td width="100" height="25"> <div align="center">
<input name="id" type="checkbox" id="id" value="<%=rs("id")%>" <%if rs("实际入库")<>"" then response.write "disabled"%>>
</div></td>
</tr>
<% rs.movenext%>
<%wend%>

b:
<%
Dim ID,II
n_bz=Request.Form("bz")
n_tj=Request.Form("tj")
ID=Request.Form("id")
II=Split(ID,",")
for i=0 to ubound(II)
sSQL ="update [j_superorder] set 实际入库='"&date()&"',包装件数='" &n_bz& "',商品体积='" &n_tj& "' where id="&II(i)
response.write sSQL
Conn.Execute(sSQL)
next

%>

执行不了!
wsqsoft 2003-12-11
  • 打赏
  • 举报
回复
发错了,重发一遍:


a:
<% while not rs.eof %>
<tr>
<input name=sid value=<%=rs("ID")%> type=hidden>
<td width="115" height="25"> <div align="center">
<input name="bz" type="text" id="bz" value="<%=rs("包装件数")%>" size="12" class="input">
</div></td>
<td width="63" height="25"><div align="center">
<input name="tj" type="text" id="tj" value="<%=rs("商品体积")%>" size="12" class="input" >
</div></td>
<td height="25"> <div align="center"><%=rs("实际入库")%></div></td>
<td width="100" height="25"> <div align="center">
<input name="id" type="checkbox" id="id" value="<%=rs("id")%>" <%if rs("实际入库")<>"" then response.write "disabled"%>>
</div></td>
</tr>
<% rs.movenext%>
<%wend%>

b:
<%
Dim ID,II,sid
n_bz=Split(Request("bz"),",")
n_tj=Split(Request("tj"),",")
sid=Split(request("sID"),",")
ID=Request.Form("id")
II=Split(ID,",")
for i=0 to ubound(sid)
if Trim(II(i))=Trim(sid(i)) and Trim(II(i))<>"" then
sSQL ="update [j_superorder] set 实际入库='"&date()&"',包装件数='" &n_bz(i)& "',商品体积='" &n_tj(i)& "' where id="&II(i)
response.write sSQL
Conn.Execute(sSQL)
end if
next

%>
wsqsoft 2003-12-11
  • 打赏
  • 举报
回复
试试这个思路:

a:
<% while not rs.eof %>
<tr>
<input name=sid value=<%=rs("ID")%> type=hidden>
<td width="115" height="25"> <div align="center">
<input name="bz" type="text" id="bz" value="<%=rs("包装件数")%>" size="12" class="input">
</div></td>
<td width="63" height="25"><div align="center">
<input name="tj" type="text" id="tj" value="<%=rs("商品体积")%>" size="12" class="input" >
</div></td>
<td height="25"> <div align="center"><%=rs("实际入库")%></div></td>
<td width="100" height="25"> <div align="center">
<input name="id" type="checkbox" id="id" value="<%=rs("id")%>" <%if rs("实际入库")<>"" then response.write "disabled"%>>
</div></td>
</tr>
<% rs.movenext%>
<%wend%>

b:
<%
Dim ID,II,sid
n_bz=Request.Form("bz")
n_tj=Request.Form("tj")
sid=request.from("sID")
ID=Request.Form("id")
II=Split(ID,",")
for i=0 to ubound(sid)
if Trim(II(i))=Trim(sid(i)) then
sSQL ="update [j_superorder] set 实际入库='"&date()&"',包装件数='" &n_bz& "',商品体积='" &n_tj& "' where id="&II(i)
response.write sSQL
Conn.Execute(sSQL)
end if
next

%>
zxlh 2003-12-11
  • 打赏
  • 举报
回复
list.asp

<!--#include file="conn.asp"-->

<%set rs=server.createobject("adodb.recordset")

rs.open "select * from data",conn,1,1

%>

<form action="update.asp" method="post">

<% do while not rs.eof%>

<input type=checkbox name=id value="<%=rs("id")%>">

<input name=<%="username"&cstr(rs("id"))%> value="<%=rs("username")%>"><br>

<%rs.movenext

loop%>

<input type="submit" value="提交">

</form>

update.asp

<!--#include file="conn.asp"-->

<%set rs=server.createobject("adodb.recordset")

id=request("id")

id=split(id,",")

for i=0 to ubound(id)

username=request("username"&id(i))

response.write username

sql="update [data] set username='"&username&"' where id="&cint(id(i))

'response.write sql

'response.end

conn.execute(sql)

next

response.write "ok"

%>




Top

回复人: annyking(anny) ( ) 信誉:116 2003-6-13 11:16:25 得分:20



先读出记录的个数(如:rowcount),然后重新定义数组大小 redim a(rowcout,3)并初始化

i=1

do while not rs.eof

a(i,1)=rs("id")

a(i,2)=rs("name")

a(i,3=rs("price")

rs.movenext

i=i+1

loop

生成网页时用

for i=1 to rowcount

response.write "<input type=text value=" & a(i,1) & " name=a" &i & "1>"

response.write "<input type=text value=" & a(i,2) & " name=a" &i & "2>"

response.write "<input type=text value=" & a(i,3) & " name=a" &i & "3>"

next

提交时

for i=1 to 提交个数

a(i,1)=request.form("a" & i & "1")

a(i,2)=request.form("a" & i & "2")

a(i,3)=request.form("a" & i & "3")

next



for ...

update 就行了

next



zxlh 2003-12-11
  • 打赏
  • 举报
回复
各位老大帮帮忙!
zxlh 2003-12-11
  • 打赏
  • 举报
回复
update [j_superorder] set 实际入库='2003-12-11',包装件数='12, 3, , , , , , ',商品体积='21, 3, , , , , , ' where id=512
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e57'

[Microsoft][ODBC SQL Server Driver][SQL Server]String or binary data would be truncated.

/yue/touser.asp,行19
xiangwangz 2003-12-11
  • 打赏
  • 举报
回复
同意楼上的,给分
zxlh 2003-12-11
  • 打赏
  • 举报
回复
楼上的不行啊!
liuzxit 2003-12-11
  • 打赏
  • 举报
回复
try...

<% while not rs.eof %>
<tr>
<td width="115" height="25"> <div align="center">
<input name="bz" type="text" value="<%=rs("包装件数")%>" size="12" class="input">
</div></td>
<td width="63" height="25"><div align="center">
<input name="tj" type="text" value="<%=rs("商品体积")%>" size="12" class="input" >
</div></td>
<td height="25"> <div align="center"><%=rs("实际入库")%></div></td>
<td width="100" height="25"> <div align="center">
<input type="checkbox" value="<%=rs("id")%>" onclick="this.parentElement.children[1].value=(this.checked?this.value:'')">
<input name="id" type="hidden"><%=rs("id")%>
</div></td>
</tr>
<% rs.movenext%>
<%wend%>


<%
Dim ID,II
n_bz=Request.Form("bz")
n_tj=Request.Form("tj")
ID=Request.Form("id")
II=Split(ID,",")
for i=0 to ubound(II)
if II(i)<>"" then
sSQL ="update [j_superorder] set 实际入库='"&date()&"',包装件数='" &n_bz& "',商品体积='" &n_tj& "' where id="&II(i)
response.write sSQL
Conn.Execute(sSQL)
end if
next

%>

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧