Making use of ASP and Access database to make the answer system on LAN online

Source: Internet
Author: User
Tags exit include odbc servervariables access database client root directory
The information society to the person's academic qualifications, the quality request is more and more high, the people in order to find the future better, the income more attractive job position, must pass all kinds of examinations such as CPA Qualification Examination, the judicial qualification examination and so on, and all kinds of examination material also emerged, But one drawback of all the data is that it is inconvenient to use, not flexible, and inefficient, the online answer system is to make up for these many inconvenience and prepared for the LAN and can operate on a stand-alone system, the following detailed introduction of the system and the use of the method.
First, the interface
As shown in the figure:

Ii. Composition of the procedure
This system is by index. The functions of ASP, lkzk.asp, save.asp, db0.fun four applet and Access database file Lkzk.mdb compose each program are:
1. Index. ASP is a frames page that is responsible for importing lkzk.asp, save.asp two subpages to form a complete program page.
2. Lkzk.asp is the interactive page generating program for random questions, which mainly completes the functions of random topic Selection, topic display, input and correct rate, total answer number display, etc.
3. Save.asp complete the answer to the correct judgment, display and registration of results (by the client IP address).
4. Db0.fun contains multiple functions (lkzk.asp, save.asp) that open an Access database.
5. Lkzk.mdb Access database file, consisting of the table "IP" and the table "Question bank".
The table (IP) consists of the Number field ID (number format), the Client Address field IP (text format), the error answer number segment nnn (number format), the correct answer number segment YYY (number format);
The table "question bank" consists of a title Number field ID (number format), a single select multiple-select tag field DX (number format), answer field XZ (text format), Question Content field NA (Memo format). (Note: The selection of the question content must be "A .....) B....... C....... D. ... " Format
---------------Index. ASP-----------------
<title> NET boss Test item Bank </title>
<frameset rows= "87%,*" framespacing= "0" >
<frame name= "Top" src= "lkzk.asp" scrolling= "Auto" >
<frame name= "Bottom" scrolling= "Auto" marginwidth= "0" marginheight= "0" >
<noframes>
<body>
<p> This page uses frames, but your browser does not support frames. </p>
</body>
</noframes>
</frameset>
--------------lkzk.asp-------------
<!--#include virtual= "/lkzk/db0.fun"-->
<%
Set RSU2 = Getmdbstaticrecordset ("Lkzk.mdb", "IP")
Set rs = getmdbstaticrecordset ("Lkzk.mdb", "Question bank")
%>
<HTML>
<title> NET boss Test item Bank </title>
<body >
<font size= "4" color= "#000080" > Department Examination Question Bank
<%
ClientIP = Request.ServerVariables ("REMOTE_ADDR")
Userip=right (Clientip,len (ClientIP)-instrrev (ClientIP, "."))
Rsu2. Absoluteposition=userip
Randomize
I=fix (rnd*1800)
Rs. Absoluteposition=i+1
%>
General <%=cstr (i+6)%> title <% ' =rs ("type")%>
<form action=save.asp method=get target= "Bottom" >
<input type=hidden name=ai value= "<%=I%>" >
<HR>
<% s=rs ("NA")
X=instr (S, "A.")
sx= "Multiple Selection"
If RS ("DX") =0 Then
sx= "Single Selection"
End If%>
<%=left (s,x-1)%> ' shows the content of the questions except the selected part
<font color= "Red" >
<%=sx%> <BR> ' Show is a radio or multiple selection
</font>
<% S=right (S,len (s)-x+1)
X=instr (S, "B.") %> ' Show check box and select section below
<input type=checkbox name=a value= "A" >
<%=left (s,x-1)%><br>
<%s=right (S,len (s)-x+1)
X=instr (S, "C.") %>
<input Type=checkbox name=a value= "B" >
<%=left (s,x-1)%><br>
<%s=right (S,len (s)-x+1)
X=instr (S, "D.") %>
<input Type=checkbox name=a value= "C" >
<%=left (s,x-1)%><br>
<%s=right (S,len (s)-x+1)%>
<input type=checkbox name=a value= "D" > <%=s%>
<BR>
<input type=submit value= "View Answers" >
<a href= "lkzk.asp" target= "_self" > Continue to do questions </a> <BR>
<%if rsu2 ("nnn") +rsu2 ("yyy") =0 then-RSU2 ("yyy") =1 end if%>
Correct rate: <%=formatnumber (RSU2 ("yyy")/(RSU2 ("nnn") +rsu2 ("yyy")) *100, 2, True)%>%
Total number of questions: <%=rsu2 ("nnn") +rsu2 ("yyy")%>
</form>
</font>
</BODY>
-----------------save.asp-------------------
<!--#include virtual= "/lkzk/db0.fun"-->
<%
Set RSU2 = Getmdbstaticrecordset ("Lkzk.mdb", "IP")
Set rs = getmdbstaticrecordset ("Lkzk.mdb", "Question bank")
%>
<HTML>
<body >
<% I=cint (Request ("AI"))
Rs. Absoluteposition=i+1
ssx= "Wrong"
A=replace (Request ("A"), ",", "" "
If A=rs ("XZ") then ' judge the correct answer
ssx= "Yes"
End If
%>
<font color=red>
You answered <%=ssx%> ' Show me the correct answer
</FONT>
Question Bank General <%=cstr (i+1+5)%> question your answer is:<%=a%>
The answer is: <%=rs ("XZ")%>
<%
ClientIP = Request.ServerVariables ("REMOTE_ADDR")
Userip=right (Clientip,len (ClientIP)-instrrev (ClientIP, "."))
Rsu2. Absoluteposition=userip
Rsu2. Update
If ssx= "to" then
RSU2 ("yyy") =rsu2 ("yyy") +1
End If
If ssx<> "to" then
RSU2 ("nnn") =rsu2 ("nnn") +1
End If
Rsu2. Update ' below records the results of the errors in the database table ' IP '
%>
</BODY>
</HTML>
--------------Db0.fun----------------
<% ' Below is a function program
'---------------------------------------------------
Function getmdbconnection (FileName)
Dim Provider, DBPath
Provider = "Provider=Microsoft.Jet.OLEDB.4.0;"
DBPath = "Data source=" & Server.MapPath (FileName)
Set getmdbconnection = getconnection (Provider & DBPath)
End Function
'---------------------------------------------------
Function Getmdbrecordset (FileName, Source)
Set Getmdbrecordset = Getmdbrs (FileName, Source, 2, "")
End Function
'---------------------------------------------------
Function Getmdbstaticrecordset (FileName, Source)
Set Getmdbstaticrecordset = Getmdbrs (FileName, Source, 3, "")
End Function
'---------------------------------------------------
Function getconnection (Param)
Dim Conn
On Error Resume Next
Set getconnection = Nothing
Set conn = Server.CreateObject ("ADODB. Connection ")
If err.number <> 0 Then Exit Function
Conn. Open Param
If err.number <> 0 Then Exit Function
Set getconnection = conn
End Function
'---------------------------------------------------
Function Getmdbrs (FileName, Source, Cursor, Password)
Dim Conn, RS
On Error Resume Next
Set Getmdbrs = Nothing
If Len (Password) = 0 Then
Set conn = getmdbconnection (FileName)
Else
Set conn = getsecuredmdbconnection (FileName, Password)
End If
If Conn is nothing Then Exit Function
Set rs = Server.CreateObject ("ADODB.") Recordset ")
If err.number <> 0 Then Exit Function
Rs. Open source, Conn, Cursor, 2
If err.number <> 0 Then Exit Function
Set Getmdbrs = rs
End Function
'---------------------------------------------------
%>
Third, the Operation method
The system operation method is to make a good test database file Lkzk.mdb together with the above four programs copy to the host's www root directory and execute http://host IP address/index.asp can answer the questions. (This program in stand-alone WINDOWS98+PWS+ODBC drive and LAN WindowsNT Server4.0 +IIS4.0+ODBC driving environment are tested through, each user can according to the specific situation of the title of the program slightly modify the production of their own test database system, It can also be expanded to add a variety of other functions, here due to the length of the relationship is no longer covered, the details of the ODBC driver can refer to the relevant information or send me a letter mailto:intcom@21cn.com.


Related Article

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.