Need help with C# DataSets

D

Dale

I'm got strange behaviour calling AcceptChanges when initialising my
DataSet.

Before calling the EndInit() method when initialising a DataSet
(auto-generated), I initialise 2 static tables within the DataSet
(table data doesn't change at runtime). The first table is loaded by a
table adapter which makes the DataSet indicate no changed rows.
However, loading the second table manually makes the DataSet indicate
changed rows; so I call AcceptChanges() which fixes the problem. After
that I setup event handlers for RowChanged and ColumnChanged, and then
call EndInit() for the DataSet.

Now the fun starts. I load the form, load the dataset with the data to
edit, set the BindingSource, which all controls on the form are bound
to, and start editing. The event handlers which were setup earlier
never get called with AcceptChanges(). If I remove the AcceptChanges()
line when initialising the database, the row and column change events
get fired off.

Can someone please explain what's going wrong?

Dale.
 
S

Storm! Sams

Are you calling AcceptChanges() after you send an update back through
the DataAdapter?.
 
D

Dale Harris

No, I'm not calling AcceptChanges() after updating through a DataAdapter.
I just populating a table with about 5 rows of static data. I then call
AcceptChanges() so that the DataSet doesn't report any changes made.
 
D

Dale Harris

Sorry, I hadn't tracked the problem far enough.

I've found that, yes, my column change event handler does get called. The
only problem is that when I inspect the event arguments, I find that the row
being modified has it's RowState set as unchanged. I presume this is my
problem and how I can fix it.

Regards,

Dale Harris.
 

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