Mysql 使用DataRow C更新现有数据
我需要更新mysql数据库中的现有数据 我这样写代码Mysql 使用DataRow C更新现有数据,mysql,datarow,Mysql,Datarow,我需要更新mysql数据库中的现有数据 我这样写代码 String _id = lbID.Text; dsrm_usersTableAdapters.rm_usersTableAdapter _t = new dsrm_usersTableAdapters.rm_usersTableAdapter(); dsrm_users _mds = new dsrm_users(); _mds.EnforceConstraints = fal
String _id = lbID.Text;
dsrm_usersTableAdapters.rm_usersTableAdapter _t = new dsrm_usersTableAdapters.rm_usersTableAdapter();
dsrm_users _mds = new dsrm_users();
_mds.EnforceConstraints = false;
dsrm_users.rm_usersDataTable _m = _mds.rm_users;
_t.FillBy4(_m, _id);
if(_m.Rows.Count >0 )
{
DataRow _row = _m.Rows[0];
_row.BeginEdit();
_row["username"] = txtUserName.Text;
_row.EndEdit();
_row.AcceptChanges();
_t.Update(_m);
}
但是我的数据没有改变。问题出在哪里?我认为问题出在调用DbDataAdapter.Update之前调用DataRow.AcceptChanges。AcceptChanges将数据行的状态设置为Original或not changed-我现在不记得了。尝试在更新后将对AcceptChanges的调用移动到。当传递带有修改行的DataRow集合时,更新需要有效的UpdateCommand 是的,我在更新后移动AccesptChange,但现在给出此错误
当传递带有修改行的DataRow集合时,更新需要有效的UpdateCommand 但现在的问题是,我使用MySQL,无法编写UpdateCommand,VS2008不接受SQL命令。自动删除所有SQL命令。我不明白这个问题。那么,您现在是否有另一种不使用SQL命令UpdateCommand的方法