Using asp.net to construct online examination system
Source: Internet
Author: User
With the popularization of computer network, the B/s online examination system based on database has been widely applied, and the ASP.net (C #) +sql server (or access) is used as an example to explain how to develop the online examination system.
First, the design of the database:
Establish the database Netexam, add examinee Information table Stuinfo in the library, establish the following fields: Test number Examid (c) (primary key), candidate name Name (c), whether to login for examination Logyn (c), score score (c), randomly generated question answer MCA (c) ( Note: Here take multiple-choice as an example, single selection, the same as the judgment question. Add Multiple-choice item Bank table MC, establish the following fields: Title question (c), four selected Choice1 (c), Choice2 (c), Choice3 (c), Choice4 (c), answer Answer (c) (Note: Multiple-choice answers with 0 for not selected, 1 for Choice , such as selecting Abd in 1101.
Second, examinee login:
Here to insert the candidate information into the table stuinfo, here to prevent candidates to repeat the login! To specify a unique test number, and the Test number field Examid (c) Set as the primary key, when repeated login, with catch catch error, give the corresponding prompts, part of the code is as follows (Login.aspx):
private void Butok_click (object sender, System.EventArgs e)
{
...
SqlConnection stuconn=new SqlConnection ("Data source=localhost;integrated Security=sspi;
Initial Catalog=netexam ");
SqlCommand Logincmd=stuconn.createcommand (); Different database connections can be selected depending on the situation
...
logincmd.commandtext= "Insert into Stuinfo (examid,name) VALUES (' +txtid.text.trim () +" ', ' "+txtname.text.trim () +") " ;
Insert the test number and name into the corresponding field, where Txtid,txtname is the text box for entering the test number and the name, respectively.
Try
{
...
session["Id"]=txtid.text.trim ();
Stuconn.open ();
Logincmd.executereader ();
Response.Redirect ("test.aspx");
}
catch (Exception)//catch the corresponding error
{
Response.Write ("<script language=" JavaScript ">" + "");
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