[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

AcceptChanges

Hi we're merging a dataset into another using the Merge function

Having problems with the new dataset not going back to the table. If we change a record in a row in the GridEx(like a DataGrid) manually, it only update that row and not the ones changes in sql. Can anyone guess why?

This is my code. Assume it's something to do with AcceptChanges. GridEx is a 3rd party control similar to a DataGrid

        'This merges the temp filtered Dataset table with the original so overwriting
        dsSQLAlarmRenewalManager.Clear()
        daSQLAlarmRenewalManager.Fill(dsSQLAlarmRenewalManager.Tbl_RenewalOffers)

        dsSQLAlarmRenewalManager.Tables(0).Merge(dsTempFiltered.Tables(0), False)

        dsSQLAlarmRenewalManager.AcceptChanges()
        GridEXAlarms.Refetch()
        'Must do this save very first thing
        GridEXAlarms.UpdateData()
        Me.daSQLAlarmRenewalManager.Update(dsSQLAlarmRenewalManager.Tbl_RenewalOffers)
GridEXAlarms.Refetch()

Know it's a bit vague, but just need a break on this!
0
StuartK
Asked:
StuartK
  • 3
1 Solution
 
StuartKAuthor Commented:
Is it connected to .AcceptChangesDuringFill?
0
 
ElrondCTCommented:
You need to do a .Update before .AcceptChanges:

daSQLAlarmRenewalManager.Update(dsSQLAlarmRenewalManager.Tbl_RenewalOffers)
dsSQLAlarmRenewalManager.AcceptChanges()

You're accepting the changes first, which clears all the flags that indicate which rows are added or modified.
0
 
StuartKAuthor Commented:
Thanks for your post. Been reading a bit more up on this, and when we merge it doesn't change the flags for Update to "Modified"

This is why we are getting anything to update cause the Update Command does't think there is anything

Apparently we need to set AcceptChangesDuringFilll = False. This chnages all the flags to Modified.

Would you say this is heading down the right lines? Still not got this sorted.

Tried AcceptChanges after Update, unfortunately it didn't work!
0
 
StuartKAuthor Commented:
Had to close off. Lost my focus on this apologies all round! Given points just for replying. Thank you ever so much for that!
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now