asp.net网络考试系分析⑵

<% @ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<Script runat="server">
string Lesson;
string No;
string Name;
OleDbDataReader dr;
void Page_Load(Object Src, EventArgs E) {
 Lesson = Request["Lesson"];
 No =  Request["No"];
 Name = Request["Name"];
 string SQL = "Select * From " + Lesson + " Order By 题号";
 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);
 dr = Comm.ExecuteReader();
}
</Script>
<HTML>
 <BODY BGCOLOR=BEIGE>
 <CENTER>
 <H1><FONT COLOR=#6699DD>在线考试系统</FONT></H1>
 </CENTER>
 <H2>考试科目 -- <%=Lesson%><HR></H2>
 <FORM Action="Score.aspx" Method="GET">
 <INPUT Type="Hidden" Name="Lesson" Value=<%=Lesson%>>
 <INPUT Type="Hidden" Name="No" Value=<%=No%>>
 <INPUT Type="Hidden" Name="Name" Value=<%=Name%>>
<%
string TestType = "";
while (dr.Read()){
 Response.Write("<B>" + dr["题号"].ToString() + "."
  + Server.HtmlEncode(dr["题目"].ToString())
  + dr["类型"].ToString() + ":" + dr["分数"].ToString() + "分)</B>");
 Response.Write("<div>");
 for (int i=1; i<5; i++) {
  if (dr["类型"].ToString() == "单选") {
   TestType = "Radio";
  } 
  else {
   TestType = "CheckBox";
  }
  Response.Write("<INPUT Type=" + TestType
   + " Name=No" + dr["题号"].ToString()
   + " Value=" + i +">"
   + Server.HtmlEncode(dr["选项" + i].ToString()) + "<BR>");
 }
 Response.Write("</div>");
}
%>
<INPUT Type=Submit Value="  交 卷  ">
</FORM><HR></BODY>
</HTML>

你可能感兴趣的:(asp.net)