RowState Problem

T

tom

Hi,

When I change existing data in my typed dataset the rowstate for that row is
added instead of modified? Here is the code I am using:

OrderDS.OrderRow orderRow = orderDS.Order[0];

orderRow.OrderID = newOrderID;
orderRow.SerialNumber = newSerialNum;
orderRow.CustomerName = newCustomerName;

? orderRow.RowState = Added

Thanks
 
W

William Ryan eMVP

Tom:

It depends on what happened with row beforehand. Put this line of code at
the beginning of the code snippet before OrderDS.OrderRow....
Debug.Assert(orderDS.Order[0].Rowstate == Rowstate.Added);

I'm betting the assertion won't fail. If you had AcceptChangesDuringFill
set the false for instance on the dataadapter, then every row would indicate
it was added. There could be other problems, but my point is that knowing
the rowstate before all of this happens would help indicate why it's added.
 
T

tom

I think I know the reason why. I do not retrieve this row of data from the
database, I manually insert the data by adding a new row. So, I am
assumming since I added this data manually by adding a new that the rowstate
is added when I modify the data. Is this the correct assumption?

Thanks

William Ryan eMVP said:
Tom:

It depends on what happened with row beforehand. Put this line of code at
the beginning of the code snippet before OrderDS.OrderRow....
Debug.Assert(orderDS.Order[0].Rowstate == Rowstate.Added);

I'm betting the assertion won't fail. If you had AcceptChangesDuringFill
set the false for instance on the dataadapter, then every row would indicate
it was added. There could be other problems, but my point is that knowing
the rowstate before all of this happens would help indicate why it's added.
"tom" <tommy> wrote in message news:[email protected]...
Hi,

When I change existing data in my typed dataset the rowstate for that
row
is
added instead of modified? Here is the code I am using:

OrderDS.OrderRow orderRow = orderDS.Order[0];

orderRow.OrderID = newOrderID;
orderRow.SerialNumber = newSerialNum;
orderRow.CustomerName = newCustomerName;

? orderRow.RowState = Added

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top