Rowstate remains unchanged for only the first dataset row

B

Ben Unsworth

When I change any information in the fields of the first row of my dataset
the rowstate does not change! It works on all other rows just not the first
one!

For example:

MyDataSet.tablename.Rows(0).Item("city") = "Toronto"
MsgBox("Rowstate: " + MyDataSet.tablename.Rows(0).RowState.ToString)

After executing the code above the MsgBox would say "Rowstate: unchanged"

However, after executing the below code, the MsgBox would say "Rowsate:
modified"

MyDataSet.tablename.Rows(1).Item("city") = "Toronto"
MsgBox("Rowstate: " + MyDataSet.tablename.Rows(1).RowState.ToString)

I am not using acceptChanges() and I tried EndEdit() and I am baffled that
everything works fine for all of the rows of my dataset except the first
one!!!

The dataset schema was generated with SQLDataAdapter automatically in Visual
Studio 2003 from a MS SQL Server 2000 Database.

Any ideas??? TIA, Ben
 
W

William Ryan

I tried the code snippet and it worked as publicized.
However, I would suggest looking at the
DataSet.GetChanges method. See if there are changes.
I'm guessing there aren't, but it's worth checking b/c I
can't reproduce the error. If it still doesn't show
changes, make a Datarow, add it, then delete it. Check
again. This will definitely/should definitely show
Changes.

I've toyed with it and if I change Toronto to Toronto, I
don't see any changes, (I'd expect that it woudl
though). Try changing Row [0] to 'Torontooooo' and see
if that shows a change.

It's hard to tell from the snippet when you are firing
each.... I'm guessing that it's probably due to a row
changed event which fires when you change the second row.

Try the same code, changing the second row, then change
it again to the same value and see if it changes.

Depending on where I set my debugger, I get different
results and it's based on the rowchanged event which
fires depending on where I set my debugger and MsgBox.

Also, Change the value in Row[0], then change the value
in row[1], then go back to row[0] and change it again,
then go back to row[1]. This will help to determine
what's going on.

I'll be up all night....good luck my friend,

Bill
(e-mail address removed)
(e-mail address removed)
 
D

Derek LaZard

Hi Ben. Not seeing a problem here...I was going to say that there could be a problem if you modify the collection directly (not via the table), but I'm not so sure about that...

[BTW, excuse the question: Are you sure Row[0]["city"] is not equal to "Toronto" initially?--the current value? ]

Derek LaZard
 

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