且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将内容行与datagrid上的现有表与数据库值进行比较

更新时间:2023-01-21 12:57:46

DataTable有一个名为GetChanges的方法,它返回在调用最后一个AcceptChanges后对表进行的所有更改。



请参阅此处 [ ^ ]更多

[代码示例]

DataTable has a method called GetChanges which returns all changes made to the table after the last AcceptChanges is called.

see here[^] for more
[Code sample]
private void UpdateDataTable(DataTable table, 
    OleDbDataAdapter myDataAdapter)
{
    DataTable xDataTable = table.GetChanges();

    // Check the DataTable for errors. 
    if (xDataTable.HasErrors)
    {
        // Insert code to resolve errors.
    }

    // After fixing errors, update the database with the DataAdapter 
    myDataAdapter.Update(xDataTable);
}