PC Review


Reply
Thread Tools Rate Thread

RowNotInTableException

 
 
Mike Kiefer
Guest
Posts: n/a
 
      10th Sep 2004
I have a typed data set with Stores and CartItems, where there is a
relationship from the Stores table to the CartItems table. Whenever a row in
the CartItems table is deleted, the following code fires as part of the
CartItems_CartItemsRowDeleted event for the dataset, deleting the parent row
if it is the last item from that store in the cart. For some reason, when
_cartDS.AcceptChanges() is called after the parent row is deleted, a
RowNotInTableException is thrown. I don't understand why this would occur
and can't figure out how to fix it or work around it. Any help would be
greatly appreciated.

Guid storeGUID = (Guid)e.Row[_cartDS.CartItems.StoreGUIDColumn,
DataRowVersion.Original];
ShoppingCartDS.StoresRow row = _cartDS.Stores.FindByStoreGUID(storeGUID);
if (row != null)
{

ShoppingCartDS.CartItemsRow[] childRows = row.GetCartItemsRows();
if ((childRows == null) || (childRows.Length == 0))
row.Delete(); // If this code isn't executed then AcceptChanges
works fine with no exceptions thrown
}


 
Reply With Quote
 
 
 
 
Mike Kiefer
Guest
Posts: n/a
 
      10th Sep 2004
Of course, as soon as I posted about the problem I figured it out...

The problem was that AcceptChanges was triggering the
Stores_StoresRowChanged event and that event handler
wasn't checking to see if (e.Row.RowState == DataRowState.Detached) before
doing it's work. Adding the proper checks solved my problem.


"Mike Kiefer" <mdk-(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>I have a typed data set with Stores and CartItems, where there is a
>relationship from the Stores table to the CartItems table. Whenever a row
>in the CartItems table is deleted, the following code fires as part of the
> CartItems_CartItemsRowDeleted event for the dataset, deleting the parent
> row if it is the last item from that store in the cart. For some reason,
> when _cartDS.AcceptChanges() is called after the parent row is deleted, a
> RowNotInTableException is thrown. I don't understand why this would occur
> and can't figure out how to fix it or work around it. Any help would be
> greatly appreciated.
>
> Guid storeGUID = (Guid)e.Row[_cartDS.CartItems.StoreGUIDColumn,
> DataRowVersion.Original];
> ShoppingCartDS.StoresRow row = _cartDS.Stores.FindByStoreGUID(storeGUID);
> if (row != null)
> {
>
> ShoppingCartDS.CartItemsRow[] childRows = row.GetCartItemsRows();
> if ((childRows == null) || (childRows.Length == 0))
> row.Delete(); // If this code isn't executed then AcceptChanges
> works fine with no exceptions thrown
> }
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
System.Data.RowNotInTableException - Why? Sasha Microsoft ADO .NET 8 20th Feb 2009 12:43 AM
RowNotInTableException - Help =?Utf-8?B?U3Rhbg==?= Microsoft ADO .NET 1 13th Apr 2006 03:40 AM
RowNotInTableException Magne Ryholt Microsoft ADO .NET 0 27th Jan 2005 05:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:56 PM.