簡易成績查詢系統

來源:互聯網
上載者:User

先建一個資料庫(std.mdb):其中有兩個表 1.pw(密碼錶) 2.score成績表
然後建兩個Jsp檔案

enter.jsp(登入頁面,用來驗正身份的)
-----------------------------------------------
<%@ page contentType="text/html;charset=gb2312"%>



請輸入你的學號和密碼



<%
String error=request.getParameter("errortype");
if(error!=null)
{
int errortype;
errortype=Integer.parseInt(error);
switch(errortype)
{
case 1:out.println("請輸入學號!");break;
case 2:out.println("請輸入密碼!");break;
case 3:out.println("搞錯,沒有此人!");break;
case 4:out.println("密碼錯誤!");break;
default:
}
}
%>

result.jsp(執行查詢結果)
--------------------------------------------

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*" %>
<%
String num=request.getParameter("number");
String password=request.getParameter("password");
int errortype=0;
if(num.equals(""))
{
errortype=1;
response.sendRedirect("enter.jsp?errortype="+errortype); JAVA天堂
}
else if(password.equals(""))
{
errortype=2;
response.sendRedirect("enter.jsp?errortype="+errortype);
}
else
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("Jdbc:odbc:std");
Statement smt=con.createStatement();
String sql="select * from pw where 學號=""+num+""";
ResultSet rs=smt.executeQuery(sql);
if(!rs.next())
{
errortype=3;
response.sendRedirect("enter.jsp?errortype="+errortype);
}
else if(!rs.getString(2).equals(password))
{
errortype=4;
response.sendRedirect("enter.jsp?errortype="+errortype);
}
else
{

sql="select * from score where 學號=""+num+""";
rs=smt.executeQuery(sql);
rs.next();
out.println(rs.getString(1)+",你好,你的成績如下:"+"

");
out.println("


< th>軟體工程

"); JAVA天堂
out.println("

"+"

");
con.close();
}
con.close();
}
%>

");out.println("
姓名 電腦英語 C程式設計 Java程式設計< /th> 資料庫原理 電腦網路
"+rs.getString(2)+" "+rs.getString(3)+" "+rs.getString(4)+" "+rs.getString(5)+" "+rs.getString(6)+" "+rs.getString(7)+" "+rs.getString(8)+"

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.