求解决!!
“System.FormatException”类型的第一次机会异常在 mscorlib.dll 中发生
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();
}