我想把GridView里某一列的float的属性值 和 我从别的函数getrecord取出来的另外的一个float值比较大小 私以为if条件里的判断条件没有语法
我想把GridView里某一列的float的属性值 和 我从别的函数getrecord取出来的另外的一个float值比较大小
私以为if条件里的判断条件没有语法问题
但是当我在datagridview里插入float值,比如7.0时,出现
未处理的“System.FormatException”类型的异常出现在 mscorlib.dll 中。
其他信息: 输入字符串的格式不正确。
这个问题,求解答!
if (Convert.ToSingle(this.dataGridView1.Rows[i].Cells[4].Value.ToString())< record.getrecord("" + this.dataGridView1.Rows[i].Cells[3].Value + ""))
SqlConnection conn = new SqlConnection(Properties.Settings.Default.sportsmeetingConnectionString1);
SqlCommand cmd1 = new SqlCommand();
SqlCommand cmd2 = new SqlCommand();
SqlCommand cmd3 = new SqlCommand();
cmd1.CommandText = "update item set athid='" + this.dataGridView1.Rows[i].Cells[0].Value + "' where itemname = '" + this.dataGridView1.Rows[i].Cells[3].Value + "'";
cmd2.CommandText = "update item set athname='" + this.dataGridView1.Rows[i].Cells[1].Value + "' where itemname = '" + this.dataGridView1.Rows[i].Cells[3].Value + "'";
cmd3.CommandText = "update item set record='" + this.dataGridView1.Rows[i].Cells[4].Value + "' where itemname = '" + this.dataGridView1.Rows[i].Cells[3].Value + "'";
cmd1.Connection = conn;
cmd2.Connection = conn;
cmd3.Connection = conn;
try
{
conn.Open();
int num = cmd1.ExecuteNonQuery();
int num1 = cmd2.ExecuteNonQuery();
int num2 = cmd3.ExecuteNonQuery();
}
catch (Exception err)
{ MessageBox.Show(err.Message); }
finally
{ conn.Close(); }
}