DataSet.GetChanges() return null C#
I try this
DataSet ds = new DataSet();开发者_开发技巧
ds.AcceptChanges();
//edit table in ds
ds.Tables[0].Rows.RemoveAt(0);
//get changes
DataSet ds2 = ds.GetChanges();
but ds2 is null, why?
Use Delete instead of RemoveAt:
//ds.Tables[0].Rows.RemoveAt(0);
ds.Tables[0].Rows[0].Delete();
RemoveAt() really removes the Row, there is no trace of it left and hence there is no Change information. Delete() just marks the row as deleted.
Maybe the table was already empty, do removing the first row didn't change anything?
精彩评论