insert.jsp~7~
资源名称:JSP02.rar [点击查看]
上传用户:top0756
上传日期:2022-08-11
资源大小:6501k
文件大小:3k
源码类别:
Jsp/Servlet
开发平台:
VBScript
- <%@ page contentType="text/html; charset=GBK" %>
- <%@ page import = "java.sql.*"%>
- <%@ page language = "java"%>
- <%@ page import = "proj112.ISOtoGb2312"%>
- <html>
- <head>
- <title>
- 添加数据
- </title>
- </head>
- <body text="#808080" link="#FF99CC" vlink="#FF8080" alink="#FF99CC" topmargin="0" leftmargin="0"><style>
- <!--
- BODY {SCROLLBAR-FACE-COLOR: #FFFFFF; SCROLLBAR-HIGHLIGHT-COLOR: #FFFFFF; SCROLLBAR-SHADOW-COLOR: #FFFFFF; SCROLLBAR-3DLIGHT-COLOR: #FFFFFF; SCROLLBAR-ARROW-COLOR: #FFAAAA; SCROLLBAR-TRACK-COLOR: #FFFFFF; SCROLLBAR-DARKSHADOW-COLOR: #FFFFFF; }
- -->
- </style>
- <%
- String idvalue = request.getParameter("name").trim();
- String capvlu = null;
- %>
- <font color="8282DC" size="5"><center>
- 添加成员成功
- </font></center><br><br>
- <%
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //载入驱动程序类别
- Connection con = DriverManager.getConnection("jdbc:odbc:dsn112"); //建立数据库链接
- Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
- ResultSet.CONCUR_READ_ONLY);
- String strSQL;
- strSQL = "INSERT INTO Info(stu_id, name, sex, " +
- "age,dept, ruxdate,tel,address) Values ('" +
- ISOtoGb2312.convert( request.getParameter("stu_id")) + "','" +
- ISOtoGb2312.convert( request.getParameter("name")) + "','" +
- ISOtoGb2312.convert( request.getParameter("sex")) + "','" +
- ISOtoGb2312.convert( request.getParameter("age")) + "','" +
- ISOtoGb2312.convert( request.getParameter("dept")) + "','" +
- ISOtoGb2312.convert( request.getParameter("ruxdate")) + "','" +
- ISOtoGb2312.convert( request.getParameter("tel")) + "','" +
- ISOtoGb2312.convert( request.getParameter("address")) + "')";
- stmt.executeUpdate(strSQL);
- ResultSet rs; //建立ResultSet(结果集)对象
- rs = stmt.executeQuery("SELECT * FROM Info"); //执行SQL语句
- %>
- <TABLE width="80%" align="center" border="0">
- <%
- //利用while循环将数据表中的记录列出
- while (rs.next())
- {
- %>
- <TR bgcolor="EcEcff" align="center">
- <TD><B><%= rs.getString("stu_id") %></B></TD>
- <TD><B><%= rs.getString("name") %></B></TD>
- <TD><B><%= rs.getString("sex") %></B></TD>
- <TD><B><%= rs.getString("age") %></B></TD>
- <TD><B><%= rs.getString("dept") %></B></TD>
- <TD><B><%= rs.getString("ruxdate") %></B></TD>
- <TD><B><%= rs.getString("tel") %></B></TD>
- <TD><B><%= rs.getString("address") %></B></TD>
- </TR>
- <%
- }
- rs.close(); //关闭ResultSet对象
- stmt.close(); //关闭Statement对象
- con.close(); //关闭Connection对象
- %>
- </TABLE>
- <CENTER>
- </CENTER><center>
- <h3><a href="add.jsp">返回</a></h3></center>
- </body>
- </html>