查看: 1522|回复: 2

[文章教程] 如何将填到ASP动态表格中的内容保存到数据库?

[复制链接]
高云松 发表于 2019-4-5 20:40:14 | 显示全部楼层 |阅读模式
就是把姓名学号以及各题分数保存到数据库的表中
ASP动态表格代码如下:
  1. <%
  2. 'session.timeout=6000
  3. 'Server.ScriptTimeOut=2000

  4. dim conn,rs,sysConfig,db
  5. db="../data/database.mdb" '数据库文件位置
  6. set conn=server.createobject("adodb.connection")
  7. conn.open "driver={Microsoft Access Driver (*.mdb)};dbq=" &Server.MapPath(""&db&"")

  8. Set rs = Server.CreateObject("ADODB.Recordset")
  9. %>
  10. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  11. <html xmlns="http://www.w3.org/1999/xhtml">
  12. <head>
  13. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  14. <title>无标题文档</title>
  15. <style type="text/css">
  16. body,td,th {
  17.         font-size: 12px;
  18. }
  19. body {
  20.         margin-left: 0px;
  21.         margin-top: 00px;
  22.         margin-right: 0px;
  23.         margin-bottom: 0px;
  24.         background-color: #9F0;
  25. }
  26. </style>
  27. </head>

  28. <body>
  29. <form id="form1" name="form1" method="post" action="savecj.asp">
  30.   <table width="60%" border="1" align="center" cellpadding="0" cellspacing="0">
  31.               <%
  32.   set rs=server.CreateObject("adodb.recordset")
  33.   rs.open "select * from TeacherPapers where PaperID="&request("id")&"",conn,1,3
  34.   %>
  35.     <tr>
  36.       <td height="30" colspan="2" align="center">添加成绩</td>
  37.     </tr>
  38.     <tr>
  39.       <td align="center">试卷名称</td>
  40.       <td align="center"><%=rs("Papername")%></td>
  41.     </tr>
  42.     <tr>
  43.       <td align="center">姓名</td>
  44.       <td align="center"><input type="text" name="textfield2" id="textfield2"  size="8" maxlength="3" /></td>
  45.     </tr>
  46.     <tr>
  47.       <td align="center">学号</td>
  48.       <td align="center"><input type="text" name="textfield3" id="textfield3"  size="8" maxlength="11" /></td>
  49.     </tr>
  50.     <tr>
  51.       <td align="center">题号</td>
  52.       <td align="center">赋分</td>
  53.     </tr>
  54.    <%            
  55.   set rs=server.CreateObject("adodb.recordset")
  56.   rs.open "select * from QuestionsXZ where PaperID="&request("id")&"",conn,1,3
  57.   
  58.    do while not rs.eof %>
  59.     <tr>
  60.       <td align='center'><%=rs("QuestionID")%></td>
  61.           <td align='center'><input name="textfield4" type="text" id="textfield4" size="6" maxlength="3"></td>
  62.     </tr>
  63.                 <%
  64.                         rs.movenext
  65.                         loop
  66.                         set rs=nothing %>
  67.       <tr>
  68.       <td colspan="2" align="center"><input type="submit" name="button" id="button" value="提交" /></td>
  69.     </tr>
  70.   </table>
  71. </form>
  72. </body>
  73. </html>
复制代码
 楼主| 高云松 发表于 2019-4-6 17:15:37 | 显示全部楼层
这是一个求代码的帖子
ttasp 发表于 2019-4-6 17:38:27 来自手机 | 显示全部楼层
呃 后面你可以直接打包代码 方便调试
ttasp 发表于 2019-4-6 17:39:22 来自手机 | 显示全部楼层
大点发邮箱小点直接附件形式
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表

在线客服

售前咨询
售后咨询
服务热线
023-58418553
微信公众号