各位师兄,帮帮忙!
我想;批量更新 成绩 ,但运行时提示 update语句语法错误 数据库中成绩字段为int型,学号为字符型,课程代码为int型
protected void Button1_Click(object sender, EventArgs e)
{
int rowCount = GridView1.Rows.Count;
OleDbCommand comm;
for (int i = 0; i < rowCount; i++)
{
connection = new OleDbConnection(ConnStr);
GridViewRow row = GridView1.Rows[i];
string StuID = row.Cells[1].Text;
string ClassID = row.Cells[2].Text;
TextBox tb = (TextBox)row.Cells[3].FindControl("cj");
string score = tb.Text.ToString();
comm = new OleDbCommand("update score2 set 成绩=" + score + " where 学号='" + StuID + "' and 课程代码="+ ClassID +"", connection);
connection.Open();
comm.ExecuteNonQuery();
connection.Close();
}