这个事件的设计是从数据库拿到最高成绩和考试次数的数据,比较本次成绩取高值并考试次数加一,然后修改回数据库。但现在修改的语句不生效但也不报错,想问问各位是什么原因。代码如下:
DataSet ds = new DataSet();
DataAccess data = new DataAccess();
string sql = "select Score,Time from Userinfo where Id='" + frmLogin.Id + "'";
data.dataCon();
ds = data.getDataSet(sql);
string ScoreMax = ds.Tables[0].Rows[0]["Score"].ToString();
string Time = ds.Tables[0].Rows[0]["Time"].ToString();
Random a = new Random();
int Score = a.Next(0, 101);
//MessageBox.Show("您本次的成绩为" + Score.ToString());
Time=(int.Parse(Time)+1).ToString();
if (Score > int.Parse(ScoreMax))
{
ScoreMax = Score.ToString();
}
MessageBox.Show(Score+" "+ScoreMax+" "+Time);
sql = "update Userinfo set Score='" + frmTest.ScoreMax + "',Time='" + frmTest.Time + "' where Id='" + frmLogin.Id + "'";
data.dataCon();
this.Close();