开发者

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜