dataset row removal

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I perform this action, bChanges still remains false.
Naturally I cannot persist the change because the dataset
appears unmodified. Why is that ???

_dsAllTables.Tables[tableName].Rows.RemoveAt(rowIndex);
bool bChanges=_dsAllTables.HasChanges();

Thanks in advance
 
Hi,

Use the Delete method rather then the RemoveAt method. This is because,
Delete marks a row for deletion, modifying the HasChanges value, whereas
RemoveAt doesn't.

Eg.:
DataRow row = data.Tables[0].Rows[3];
row.Delete();

Have a look at:
www.msdn.microsoft.com/library/en-us/
cpguide/html/cpconDeletingDataRowFromDataTable.asp

HTH,
Rakesh Rajan
 
Andrew,

In addition to Rakesh

A remove(at), really removes a row from a datarowcollection.
A delete marks it as to be deleted. What is done with the acceptchanges.

A delete from a newly inserted datarow acts the same as a remove by the way.

Just a little addition,

Cor
 
THANKS,
System.Data.DataRow dr = _dsAllTables.Tables[tableName].Rows[rowIndex];
dr.Delete();
bool bChanged=_dsAllTables.HasChanges();

WORKS PERFECTLY.
 
Back
Top