Forced to use Table.Rows(...).EndEdit when using data binding

G

Guest

I have a windows form with controls bound to an underlying table in a
dataset. A data adapter is used to manage the flow of data between SQL server
and dataset. I navagate the table using the currency manager.

I have found that unless I explicitily use the .EndEdit() method of the row
that I'm currently editing, subsequent calls to the data adapter's update
method fail to write the changes to the database. Remarkably, the edits can
be seen in the dataset, but for some reason, without that Rows(x).EndEdit(),
the changes never make it back to the SQL server. I've tried calling the
CurrencyManager.EndCurrentEdit, but that does not seem to solve the problem.

Am I doing something wrong?
 
W

W.G. Ryan eMVP

Michael:

When you say the changes can be seen - how are you establishing that? What
I'm getting at is if you check for DataSet.HasChanges right before you call
the update statement (in the scenario where the update isn't working as you
want), does it evaluate to true?
 
S

Steven Cheng[MSFT]

Hi Michael,

Thank you for the posting. Regarding on the issue, I am
finding proper resource to assist you and we will update as soon as posible.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security(This posting is provided "AS IS",
with no warranties, and confers no rights.)
 
G

Guest

Sorry it took so long to get back. Yes, DataSet.HasChanges is TRUE prior to
the .Update(). In the past a simple call to CurrencyManager.EndCurrentEdit
made sure that things went correctly. I will play around with the code a bit
more. I wonder if the CurrencyManager is going to still be around in ADO .NET
when VS 2005 comes out. Thanks

Michael
 
K

Kevin Yu [MSFT]

Hi Michael,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you wonder why we should call EndEdit
before updating the data source from DataSet. If there is any
misunderstanding, please feel free to let me know.

I think this is by design. When we're trying to edit a row, the DataSet
enters edit mode. It enables us to roll back changes if you need to cancel
your modification. The edit mode will be ended as soon as the control lost
focus or CurrencyManager is moved to another position. At this point,
EndCurrentEdit is called automatically.

However, in your first post, you mentioned that the EndCurrentEdit doesn't
solve the problem. Could you try to check if there is anything wrong with
the BindingContext? Is the CurrencyManager get from correct data source and
data member?

If it still doesn't help. I would be appreciate if you could post some of
the code here. HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

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