日期:2014-05-18  浏览次数:20928 次

C#保存到数据库
我用datatable保存了修改后的表信息,怎么才能让他保存到数据库,用devexpress控件gridview做的

------解决方案--------------------
public int Updata(DataSet MyDS, DbTransaction mytran)
{
int rowAction = 0;
this.dbAdapter.SelectCommand = this.CommandforCommandBiuder;
this.dbAdapter.SelectCommand.Transaction = mytran;
this.dbAdapter.UpdateCommand = CommandBiuder.GetUpdateCommand();
this.dbAdapter.InsertCommand = CommandBiuder.GetInsertCommand();
this.dbAdapter.DeleteCommand = CommandBiuder.GetDeleteCommand();
this.dbAdapter.UpdateCommand.Transaction = mytran;
this.dbAdapter.InsertCommand.Transaction = mytran;
this.dbAdapter.DeleteCommand.Transaction = mytran;
rowAction = this.dbAdapter.Update(MyDS, this.TableName);
return rowAction;
}
整个表甚至整个DataSet更新