Home All Groups Group Topic Archive Search About
Author
11 Nov 2006 4:31 AM
Ant
VS2003, C#

Hi,

I am adding rows into a parent & child tbl. First the parent tbl, then the
child.  I have a list box & datagrid bound to a dataset displaying
parent/child rows. Both row adds are nested in a transaction. Within the
transaction I add the row(s), update the data source & accept the changes to
the DS.

If an error occurs, I rollback the transaction & reject the changes to the DS.

However, if an error occurs, although the new row (in the parent tbl) is not
persisted to the DB, it shows up in the list box that is bound to the dataset
until I restart the app.

I tried refilling the dataset in the catch but that doesn't seem to work. I
thought either rejecting the changes or refilling the DS would fix this but
no go.

Why is this happening?

Thanks for any ideas

Ant

Author
13 Nov 2006 2:59 PM
Cowboy (Gregory A. Beamer)
Are you using the Update() method on the DataSet? If so, you have two
choices:

1. Rebind with the original rowset
2. Clear the dataset completely and rebind from the database

Make sure you have completely rolled back or committed prior to grabbing.

One suggestion:
If adding records to a dropdown, do it on a separate form and raise an event
to clear out the data. NOTE: you have to clear the dropdown and then refill
when you leave things in an inconsistent state.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************
Show quote
"Ant" <A**@discussions.microsoft.com> wrote in message
news:AD48431E-0E09-424A-A1F3-E259F56587F9@microsoft.com...
> VS2003, C#
>
> Hi,
>
> I am adding rows into a parent & child tbl. First the parent tbl, then the
> child.  I have a list box & datagrid bound to a dataset displaying
> parent/child rows. Both row adds are nested in a transaction. Within the
> transaction I add the row(s), update the data source & accept the changes
> to
> the DS.
>
> If an error occurs, I rollback the transaction & reject the changes to the
> DS.
>
> However, if an error occurs, although the new row (in the parent tbl) is
> not
> persisted to the DB, it shows up in the list box that is bound to the
> dataset
> until I restart the app.
>
> I tried refilling the dataset in the catch but that doesn't seem to work.
> I
> thought either rejecting the changes or refilling the DS would fix this
> but
> no go.
>
> Why is this happening?
>
> Thanks for any ideas
>
> Ant
>
>

AddThis Social Bookmark Button