I've got a really simple database with an even simpler user interface designed to just view and edit data. The problem is that when I run the solution everything works as it is supposed to, but when I close the solution and then restart, all my record data changes are not saved to the database. Its like the record changes are temparily saved to the dataset and not saved to the database, and when the applicaiton is closed the changes to records in the dataset go back to their previous state. If you want to look at the entire application then just email me its only 130K zipped.
Heres the code that I have for the menuitem Update:
PrivateSub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuUpdate.Click
txtDateModified.Text = Now 'used to monitor updates - fills a form textbox that is bound to a database field
Call EditState(False) 'editstate locks or unlocks form textboxes
Call Calculations() 'a few math calculations repeatly performed on textboxes
Dim pdsInsertedRows, pdsModifiedRows, pdsDeletedRows As DataSet
pdsDeletedRows = DsWidgets1.GetChanges(DataRowState.Deleted)
pdsInsertedRows = DsWidgets1.GetChanges(DataRowState.Added)
pdsModifiedRows = DsWidgets1.GetChanges(DataRowState.Modified)
IfNot pdsInsertedRows IsNothingThen
OleDbDataAdapter1.Update(pdsInsertedRows)
EndIf
IfNot pdsModifiedRows IsNothingThen
OleDbDataAdapter1.Update(pdsModifiedRows)
EndIf
IfNot pdsDeletedRows IsNothingThen
OleDbDataAdapter1.Update(pdsDeletedRows)
EndIf
Me.BindingContext(DsWidgets1, "tblWidgets").EndCurrentEdit()
DsWidgets1.AcceptChanges()
EndSub
I'm not sure what the problem is, maybe theres another way to update the database. I recreated the database and recoded a new identical application and have the gotten the same results, it won't save the updates. If anyone wants see the entire thing just email. This entire application is just for learning purposes which is why it is so small. The goal was to add a field by which I could monitor changes to the database through, the datemodified field, and then to be able to sort the database by this field later on to find the changed fields and use them to update a master database. An example of the practical use would be different salespeople using the same database with everyone adding different clients to the database. There would be a need to see all the different changes made and then to update the master database and then redistribute it.
Heres the code that I have for the menuitem Update:
PrivateSub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuUpdate.Click
txtDateModified.Text = Now 'used to monitor updates - fills a form textbox that is bound to a database field
Call EditState(False) 'editstate locks or unlocks form textboxes
Call Calculations() 'a few math calculations repeatly performed on textboxes
Dim pdsInsertedRows, pdsModifiedRows, pdsDeletedRows As DataSet
pdsDeletedRows = DsWidgets1.GetChanges(DataRowState.Deleted)
pdsInsertedRows = DsWidgets1.GetChanges(DataRowState.Added)
pdsModifiedRows = DsWidgets1.GetChanges(DataRowState.Modified)
IfNot pdsInsertedRows IsNothingThen
OleDbDataAdapter1.Update(pdsInsertedRows)
EndIf
IfNot pdsModifiedRows IsNothingThen
OleDbDataAdapter1.Update(pdsModifiedRows)
EndIf
IfNot pdsDeletedRows IsNothingThen
OleDbDataAdapter1.Update(pdsDeletedRows)
EndIf
Me.BindingContext(DsWidgets1, "tblWidgets").EndCurrentEdit()
DsWidgets1.AcceptChanges()
EndSub
I'm not sure what the problem is, maybe theres another way to update the database. I recreated the database and recoded a new identical application and have the gotten the same results, it won't save the updates. If anyone wants see the entire thing just email. This entire application is just for learning purposes which is why it is so small. The goal was to add a field by which I could monitor changes to the database through, the datemodified field, and then to be able to sort the database by this field later on to find the changed fields and use them to update a master database. An example of the practical use would be different salespeople using the same database with everyone adding different clients to the database. There would be a need to see all the different changes made and then to update the master database and then redistribute it.