问题描述
解决方案
string score="";
DataSet ds = new DataSet();
private void button2_Click(object sender, EventArgs e)
{
if(!score.Equals(""){//注意score是不是没有赋值
int a = Convert.ToInt16(score);
int b = Convert.ToInt32(DBHelper.sco);
if (a > b)
DBHelper.sco = score;
string sql = string.Format("update Users set Score='{1}' where Name='{0}'", DBHelper.id, DBHelper.sco);
ds = DBHelper.chaxun (sql);
ScoreForm sf = new ScoreForm();
sf.Show();
this.Close();
}
}
解决方案二:
你这描述也太不清晰了
现在只知道是做类型转换的时候出错了
解决方案三:
string score="";
DataSet ds = new DataSet();
private void button2_Click(object sender, EventArgs e)
{
int a = Convert.ToInt16(score);
int b = Convert.ToInt32(DBHelper.sco);
if (a > b)
DBHelper.sco = score;
string sql = string.Format("update Users set Score='{1}' where Name='{0}'", DBHelper.id, DBHelper.sco);
ds = DBHelper.chaxun (sql);
ScoreForm sf = new ScoreForm();
sf.Show();
this.Close();
}
时间: 2024-07-31 07:51:52