DataSet.HasChanges problem

D

DellaCroce

I have a strange situation going on. I have a set of textboxes bond to a
dataset (ds1) that I present to the user one at a time with navigation
buttons (First-Next-Prev-Last) if they make a change in any of the enabled
textboxes and click a button I first check in the click event for
ds1.HasChanges. If true I do the Update, then reposition the record.
Sounds straight forward, right?

Well if I change a value in a textbox and hit any of the buttons .HasChanges
does not come up true. BUT if I move back to that record the .HasChanges is
true and the correct record is updated. So, change the name in the first
record, click next, .HasChanges=False, click on prev, .HasChanges=True and
the update is done. This happens every time. It is not just the code in
the Next or Prev button clicks, because it happens with First and Last too,
and it happens if I do a Next Click, change the 2nd record, click prev,
..HasChanges = False, click next, and .HasChanges=True.

Any ideas or websites to help me on this one.

Thanks in advance,
 
C

Cor

Hi DellaGroce,

Put this for your hasChanges. (The right table of course)

DirectCast(BindingContext(ds.Tables(0)), CurrencyManager).EndCurrentEdit()

I hope this helps?

Cor
 
D

DellaCroce

Cor, thanks for the help! I don't, however understand where this would go.
1. is this in place of the ds1.HasChanged (ds1.DirectCast....)?
2. is this to go in before the ds1.hasChanged in the Click event?
3. Am I just being dense and missing the point?

I tried putting it in before the .HasChanged, it had no effect. The
EndCurrentEdit() does not return a value, nor does it allow me to set it to
True. So I think that the 3rd option is the most likely! :-(
This is the code that starts all my Click events: (ProductUpdate is my
update function)
If dsProduct.HasChanges Then

Dim sProdName As String

sProdName =
dsProduct.Tables("Products").Rows(cmProduct.Position)("ProductName")

If ProductUpdate(sProdName) = False Then

MessageBox.Show("Error in Update," & vbCrLf & "Please notify
administrator")

End If

End If
 
C

Cor

Hi Della Croce

DirectCast(BindingContext(dsProduct.Tables("Products")), _
CurrencyManager).EndCurrentEdit()
If dsProduct.HasChanges Then
etc.

Cor
 

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