Track deleted rows from dataset  
Author Message
vutkuri





PostPosted: .NET Framework Data Access and Storage, Track deleted rows from dataset Top

I am using Dataadapter to update the records. Call select statement to fill the dataset, Add/update/Delete rows to and from the dataset. Call update method to update the records. Now the problem is to track the deleted rows. If i check using rowstate property of the row as deleted. But i wanted to know the row items which has been deleted. If i use row[ColumnName] then it throws exception "deleted rows cannot be accessed". Is there any solution to know the items in the deleted row. Please let me know.

foreach(DataRow row in this.Tables[Table1].GetChanges().Rows)
{
if(row.RowState == DataRowState.Deleted
)
{
writer.WriteStartElement(DData.TABLE_NAME,null
);
writer.WriteAttributeString(DData.ROW_ID
,"DELETED");
writer.WriteAttributeString(DData.DEAL_STATE
,"DELETED");
writer.Wri****dElement
();
//continue; i don't want handle in the above way. rather i wanted to get the items in the table.
} else
{
writer.WriteStartElement(DData.TABLE_NAME,null
);
writer.WriteAttributeString(DData.ROW_ID,row[ROW_ID].ToString
());
writer.WriteAttributeString(DData.DEAL_STATE,this.GetErrorStatus(row
));
writer.Wri****dElement
();
}
}




.NET Development31  
 
 
Jason D. Camp





PostPosted: .NET Framework Data Access and Storage, Track deleted rows from dataset Top

DataSet DeletedRowsDS = myDataSet.GetChanges(DataRowState.Deleted);

 
 
vutkuri





PostPosted: .NET Framework Data Access and Storage, Track deleted rows from dataset Top

I get the following error message.

"Deleted row information cannot be accessed through the row."



 
 
Jason D. Camp





PostPosted: .NET Framework Data Access and Storage, Track deleted rows from dataset Top

http://www.dotnet247.com/247reference/msgs/54/272989.aspx

 
 
vutkuri





PostPosted: .NET Framework Data Access and Storage, Track deleted rows from dataset Top

I appreciate your answer. you brought me closer but the problem is not yet resolved.

I replaced code as following to get the itemdata. This was usefull but doesn't return any data and doesn't throw exception. But my goal was not acheived.

writer.WriteAttributeString(DData.ROW_ID,row[ROW_ID,DataRowVersion.Original].ToString())



 
 
Jason D. Camp





PostPosted: .NET Framework Data Access and Storage, Track deleted rows from dataset Top

Post the snippet of code you are having problems with and I'll try it on my end.

 
 
vutkuri





PostPosted: .NET Framework Data Access and Storage, Track deleted rows from dataset Top

Hi Jason

Your answer did help me in fixing the problem. It was my mistake, i was trying to fetch the column value which was not passed to the delete statement.

row[DData.CUSCOL,DataRowVersion.Original].ToString() //This statement worked.