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

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.keywords.focus();
  9. return false;
  10. }
  11. return true;
  12. }</script>
  13. </head>
  14.   <BODY  background="img/main_5.jpg"><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 stu001 WHERE stu_id LIKE '%" + str + "%'");
  34.         out.print("<table  width='100%' cellspacing='0' cellpadding='4' rules='all' bordercolor='#CC9966' border='1' id='dg_rxkb' style='background-color:White;border-color:#CC9966;border-width:1px;border-style:None;width:99%;border-collapse:collapse;'>");
  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 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.  <FORM name="form1" Action="" Method="POST">
  62. <table  width="100%" cellspacing="0" cellpadding="4" rules="all" bordercolor="#CC9966" border="1" id="dg_rxkb" style="background-color:White;border-color:#CC9966;border-width:1px;border-style:None;width:99%;border-collapse:collapse;">
  63. <tr >
  64.       <td height="40" colspan="2"><div align="center" ><font  size="5" color="#000000"><strong>查找信息</strong></font></div></td>
  65.     </tr>
  66. <tr ><td><font color="000000" size="4">输入姓名关键字:</td>
  67. <td><INPUT Type="Text" Name="keywords" Value="<%=str%>"></td></tr>
  68. <tr ><td  height="35" colspan="2"><div align="center"><INPUT Type=Submit Value=" 查找" onClick="return a()" ></td></tr></table>
  69. </FORM>
  70. </BODY></HTML>