Thursday, January 31, 2013 5:36 AM
I have a forms app that has a local sqlce database file with the sync framework setup to sync it to a remote sql database. Everything works fine as far as syncing goes, however it has an odd behavior. When the application manipulates and makes updates to the local data, subsequent actions continue to use the original, pre-update values until the database is synced.
Application loads a screen that displays a database value of 1
Application updates database value to 2
Applications loads screen again and shows pre-update value of 1
Application loads screen again and now shows correct updated value of 2
Is there some setting of the sync framework or database I'm missing?
Thursday, January 31, 2013 11:14 AMModeratoryou might want to post/expound how you're saving changes to your database.
Thursday, January 31, 2013 12:46 PM
I think that's probably the step that's missing, because I'm currently not doing anything explicit to save them, as there doesn't seem to be any methods exposed to do that. It occurred to me after I posted that it's probably saving the changes automatically when it syncs, but I can't see how to do it manually.
I have several table adapters created in the xsd, and then added to my form, so my inserts and updates are performed like so:
There's no DataAdapater like I'm familiar with in linq to call SaveChanges or Update on, so I don't know how it's supposed to be accomplished in this scenario.
Thursday, January 31, 2013 1:01 PMModeratorI would check how you bind your controls to your data source. also, when you call insert, do you actually refresh the binding or data source? do you have like DataSet.AcceptChanges()? sorry, its been a while since I did this direct data binding thing...
- Edited by JuneTMVP, Moderator Thursday, January 31, 2013 1:05 PM
Thursday, January 31, 2013 1:12 PM
There is no direct data binding or binding sources, everything is done programmatically.
Data is added to the form by using a TableAdapater's GetData method and then iterating through the rows. Later on when it's time to update, the controls data is read, processed, and then the appropriate insert/update method is called.
I'm also noticing that it seems that only one of the tables is experiencing the issue. So I think it's something in the configuration somewhere, not something wrong in the code logic.
Thursday, January 31, 2013 1:23 PMModeratorI am almost certain sync fx has nothing to do with it though. its probably more on binding or committing changes or refreshing the data
Thursday, January 31, 2013 1:40 PM
I did add the DataSet to the form and then called AcceptChanges() on it at the end of each method and it didn't effect anything.
I'm also noticing that it seems to be just this one table adapter select method with the issue, not necessarily the underlying table. There's essentially two tables in play, a details table and a summary table. They start at the summary form and then go into a details form. When the form is loaded, the detail records are shown to the user. They update the values, and then hit save, which crunches the changed data in the controls and then uses a table adapter to insert/update the detail records. It then calls another method which retrieves those detail records and crunches a summary based on them. this summary is getting crunched correctly using the updated values, then inserts/updates with another table adapter. The details form is then closed, and the original summary form is refreshed, which now shows the correct updated summary. But if they go back into the details form, it's as if they had made no changes.
Going back over all that in my head, it sounds like the most probable answer is that it's a problem with the query.
- Edited by Justin D Funk Thursday, January 31, 2013 2:47 PM
Monday, February 04, 2013 3:06 AM
I finally figured this one out, and all I can say is wow. I absolutely hate this language and framework right now.
Seems that somewhere along the way it decided to update the connection parameter in the dataset xsd of some of the table adapters to load from the server rather then the local connection.