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

Jsp/Servlet

开发平台:

VBScript

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