我很久沒用ADO.NET操作數(shù)據(jù)了,現(xiàn)在有個WinForm項目需要用到,知識都忘完了。以下是我寫的更新,大家看看缺少點什么嗎?我點擊更新的時候數(shù)據(jù)顯示更新,但是不更新數(shù)據(jù)庫。int num = 0; for (int i = 0; i < this.dataGridView1.SelectedRows.Count;i++ ) { int id = Convert.ToInt32(this.dataGridView1.SelectedRows[i].Cells[i].Value.ToString()); //MessageBox.Show(id+"show"); OleDbConnection conn = Dbconnection.Getcon(); conn.Open(); OleDbCommand command = new OleDbCommand("update Users set UserState='1' where UserID=" + id.ToString(), conn); num = command.ExecuteNonQuery(); conn.Close(); } MessageBox.Show("刪除成功"); dataBind();
弱弱的問下大家一個ADO.NET更新問題?
慕的地6264312
2018-11-01 05:02:34