Asp.net Network Examination System Analysis

Source: Internet
Author: User

/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>

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.