insert.jsp~10~
资源名称:JSP02.rar [点击查看]
上传用户:top0756
上传日期:2022-08-11
资源大小:6501k
文件大小:2k
源码类别:
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;
- %>
- <br><br>
- <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,stu_password) 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")) + "','" +
- ISOtoGb2312.convert( request.getParameter("stu_password")) + "')";
- stmt.executeUpdate(strSQL);
- ResultSet rs; //建立ResultSet(结果集)对象
- rs = stmt.executeQuery("SELECT * FROM Info"); //执行SQL语句
- rs.close(); //关闭ResultSet对象
- stmt.close(); //关闭Statement对象
- con.close(); //关闭Connection对象
- %>
- <script language="JavaScript">
- alert("添加成功");
- location.href='add.jsp'
- </script>
- <CENTER>
- </CENTER><center>
- <h3><a href="add.jsp">返回</a></h3></center>
- </body>
- </html>