stu1.jsp~11~
上传用户:top0756
上传日期:2022-08-11
资源大小:6501k
文件大小:2k
源码类别:

Jsp/Servlet

开发平台:

VBScript

  1. <%@page contentType="text/html;charset=gb2312"%>
  2. <%@page import="java.sql.*"%>
  3. <HTML>
  4.   <head><SCRIPT language="JavaScript">
  5. function a() {
  6. if(form1.keywords.value==""){
  7. alert("用户名不能为空,请确定后重新输入");
  8. form1.username.focus();
  9. return false;
  10. }
  11. return true;
  12. }</script>
  13. </head>
  14.   <BODY ><br><br><br><br>
  15. <%
  16. Connection conn = null;
  17. Statement stmt = null;
  18. ResultSet rs = null;
  19. try{
  20. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  21. }
  22. catch(ClassNotFoundException ce){
  23. out.println(ce.getMessage());
  24. }
  25. request.setCharacterEncoding("GBK");
  26. String str = request.getParameter("keywords");
  27. if( str == null)
  28. str = "";
  29.       else
  30. try{
  31. conn=DriverManager.getConnection("jdbc:odbc:dsn112");
  32. stmt=conn.createStatement();
  33.         rs=stmt.executeQuery("SELECT * FROM stu WHERE name LIKE '%" + str + "%'");
  34.         out.print("<TABLE  align='center' width='70%'  BORDER='0'>");
  35.          out.print("<tr bgcolor='EcEcff' align='center'><TD>学期号</TD>");
  36.        out.print("<TD>课程号</TD>");
  37. out.print("<TD>课程名</TD>");
  38.                 out.print("<TD>学分</TD>");
  39.                 out.print("<TD>成绩</TD>");
  40.                 out.print("<TD>重修成绩</TD>");
  41.        out.print("<TD>主讲老师</TD></TR>");
  42. while(rs.next()){
  43. out.print("<tr bgcolor='FFEFEF' align='center'><TD>"+rs.getString("xq_id")+"</TD>");
  44. out.print("<TD>"+rs.getString("co_id")+"</TD>");
  45. out.print("<TD>"+rs.getString("co_name")+"</TD>");
  46. out.print("<TD>"+rs.getString("credit_hour")+"</TD>");
  47.                 out.print("<TD>"+rs.getString("cj")+"</TD>");
  48.                  out.print("<TD>"+rs.getString("cxcj")+"</TD>");
  49. out.print("<TD>"+rs.getString("teacher")+"</TD></TR>");
  50. }
  51. out.print("</TABLE>");
  52. }
  53. catch(SQLException e){
  54. System.out.println(e.getMessage());
  55. }
  56. finally{
  57. stmt.close();
  58. conn.close();
  59. }
  60. %>
  61. <br><br>
  62. <br><br>
  63.  <FORM name="form1" Action="" Method="POST">
  64. <table width="70%"  border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#A5C1CC">
  65. <tr bgcolor="#fcd56c">
  66.       <td height="40" colspan="2"><div align="center" ><font  size="5" color="#000000"><strong>查找信息</strong></font></div></td>
  67.     </tr>
  68. <tr ><td><font color="000000" size="4">输入姓名关键字:</td>
  69. <td><INPUT Type="Text" Name="keywords" Value="<%=str%>"></td></tr>
  70. <tr bgcolor="#fcd56c"><td  height="35" colspan="2"><div align="center"><INPUT Type=Submit Value=" 查找" onClick="return a()" ></td></tr></table>
  71. </FORM>
  72. </BODY></HTML>