A
Ayoa
I have the following code whose purpose is to take 2 typed datasets (of type
DSAccounts ) & remove all elements of one from the other. and return what
is left.
However I am getting the error message "The given datarow is not in the
current DataRowCollection" when the "dtAll.tblAccounts.Rows.Remove(dr);"
line executes. I have debugged and found that the data to be deleted is
definitely present in the master dataset.
What am i doing wrong?? Please help!
private DSAccounts RemoveFromDS(DSAccounts dtAll, DSAccounts dtRemove ) {
try {
string account;
foreach (DSAccounts.tblAccountsRow dr in dtRemove.tblAccounts.Rows) {
account = dr[0].ToString();
if (dtAll.tblAccounts.Rows.Contains(account))
dtAll.tblAccounts.Rows.Remove(dr);
}
return dtAll;
}
catch (Exception e) {
throw e;
}
}
DSAccounts ) & remove all elements of one from the other. and return what
is left.
However I am getting the error message "The given datarow is not in the
current DataRowCollection" when the "dtAll.tblAccounts.Rows.Remove(dr);"
line executes. I have debugged and found that the data to be deleted is
definitely present in the master dataset.
What am i doing wrong?? Please help!
private DSAccounts RemoveFromDS(DSAccounts dtAll, DSAccounts dtRemove ) {
try {
string account;
foreach (DSAccounts.tblAccountsRow dr in dtRemove.tblAccounts.Rows) {
account = dr[0].ToString();
if (dtAll.tblAccounts.Rows.Contains(account))
dtAll.tblAccounts.Rows.Remove(dr);
}
return dtAll;
}
catch (Exception e) {
throw e;
}
}