/Files/izxp/kaoshi.rar
<% @ Page Language = "C #" %>
<% @ Import Namespace = "System. Data" %>
<% @ Import Namespace = "System. Data. OleDb" %>
<Script runat = "server">
Void Page_Load (Object Src, EventArgs E ){
String No = "";
String Name = "";
String Lesson = "";
String Msg = "";
If (IsPostBack) {// executed when the page is submitted
No = Request ["txtNo"];
Name = Request ["txtName"];
Lesson = Request ["Lesson"];
String SQL = "Select * From transcript ";
SQL = SQL + "Where student ID =" + "'" + No + "'" + "And Name = '" + Name + "'";
// String SQL = "Select * From transcript where student ID = '" + No + "' and Name = '" + Name + "'";
OleDbConnection Conn;
Conn = new OleDbConnection ("Provider = Microsoft. Jet. OLEDB.4.0;" +
"Data Source =" + Server. MapPath ("test. mdb "));
Conn. Open ();
// Response. Write (SQL );
OleDbCommand Comm = new OleDbCommand (SQL, Conn );
OleDbDataReader dr = Comm. ExecuteReader ();
If (dr. Read ()){
If (dr [Lesson]. ToString ()! = "-1 "){
Msg = "you have taken this subject! ";
}
Else {
Conn. Close ();
Response. Redirect ("TEST. ASPX? Lesson = "+ Lesson +" & Name = "+ Name +" & No = "+ No );
// Response. Redirect ("TEST. ASPX? Lesson = "+ Lesson +" & Name = "+ Name +" & No = "+ No + "");
}
}
Else {
Msg = "you are not a valid candidate! ";
}
Message. Text = Msg;
Conn. Close ();
}
}
</Script>
<HTML>
<Body bgcolor = BEIGE>
<H1 ALIGN = "CENTER"> online examination system </H1>
<HR>
<Form method = "POST" RUNAT = "SERVER">
<Asp: DropDownList ID = "Lesson" RUNAT = "server">
<Asp: ListItem value = "ASP" selected = "true"> ASP </asp: ListItem>
<Asp: ListItem value = "XML"> XML </asp: ListItem>
</Asp: DropDownList>
<P> name: <asp: textbox id = "txtName" runat = "server"/> </P>
<P> Student id: <asp: textbox id = "txtNo" runat = "server"/> </P>
<P> <asp: button text = "Start test" runat = "server"/> </P>
</FORM> <HR>
<Asp: label id = "Message" runat = "server"/>
</BODY>
</HTML>