Conn.Open();
SQL = "Select * From 成绩单 ";
SQL = SQL + "Where 学号=" + "'" + No + "'" + " And 姓名='" + Name + "'";
Comm = new OleDbCommand(SQL,Conn);
OleDbDataReader drScore = Comm.ExecuteReader();
if(drScore.Read()){
if (drScore[Lesson].ToString() == "-1") {
SQL = "update 成绩单 set " + Lesson + " = " + Score.ToString()
+ " where 学号=" + "'" + No + "'"
+ " And 姓名='" + Name + "'";
Conn.Close();
Conn.Open();
Comm = new OleDbCommand(SQL,Conn);
Comm.ExecuteNonQuery();
}
else {
Response.Write ("<script>{alert('你已经考过了')}</script>");
}
<%//重新读取成绩
Conn.Close();
Conn.Open();
SQL = "Select * From 成绩单 ";
SQL = SQL + "Where 学号=" + "'" + No + "'" + " And 姓名='" + Name + "'";
Comm = new OleDbCommand(SQL,Conn);
drScore = Comm.ExecuteReader();
if(drScore.Read()){
%>
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>");