ASP根据数据表结构自动生成数据录入页面

 这种方法很方便但可能会不够灵活
<%
if request("Submit1")="提交" then
 Set rs1=server.createobject("adodb.recordset")
 sql1="select * from tb_user"
 rs1.open sql1,conn,1,3
 rs1.addnew
 for i=0 to rs1.fields.count-1
  if i<>0 then
   rs1(rs1.fields(i).name)=request("txt"&i)
  end if
 next
 rs1.update
 response.write("<script language=javascript>alert('提交成功')</script>")
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>根据数据表结构自动生成数据录入页面</title>
<style type="text/css">
<!--
.style1 {
 font-size: 12pt;
 color: #FFFFFF;
}
-->
</style>
</head>

<body>
 <%

'查询所要用户的信息
Set rs1=server.createobject("adodb.recordset")
sql1="select * from tb_user"
rs1.open sql1,conn,1,3

%>
 <form name="form1" method="post" action="">
   <table width="40%" border="1" align="center" cellpadding="0" cellspacing="0">
   <tr bgcolor="#FF9933">
   <td height="28" colspan="2"><div align="center" class="style1">用户资料</div></td>
   </tr>
<%
for i=0 to rs1.fields.count-1
if i<>0 then
%>
     <tr>
       <td width="29%">  <%=rs1.fields(i).name%> </td>
       <td width="71%"><input type="text" name="Txt<%=i%>"></td>
     </tr>
<%
end if
next
%>
     <tr align="center">
       <td colspan="2"><input name="Submit1" type="submit" id="Submit1" value="提交">
        
       <input type="reset" name="Submit2" value="重置"></td>
     </tr>
   </table>
 </form>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值