F
Frank
Hello,
Developing an app where the user fills out a sometimes quite lengthy
form of chkboxes, txtboxes, radbtns, etc. User responses are saved to
a mySql db, which the user can later edit.
When the user chooses to edit, I pull the responses from the db, toss
them in a dataset, check the checks, fill the txtboxes, etc.,etc.
The user then adds, deletes, or changes entries as needed and clicks
the Save Changes button. Here is where the fun begins....
I have to keep track of changes made to the saved form and mark those
items that have 'changed' as well as inserting the new editions to the
database.
My logic so far is this: When they click the Save Changes btn, I throw
all the responses into a new dataset and then compare the original
dataset to the new dataset.
Basically, if an anwer exits in dataset 1 (the original), but not in
dataset 2, that anwer was changed. Conversely, if an answer exits in
dataset 2 (the edited version), but not in dataset1, that answer was
added.
My question is: How can I best compare the 2 datasets, see what has
changed and update the db accordingly, while being minfull that NO
entries can be deleted, only marked as changed or added.
Here is some code that I have tried (from my head):
for i = 0 to dataset1.tables(0).count -1
for j = 0 to dataset2.tables(0).count - 1
if dataset1.tabels(0).rows(i)(3).tostring =
dataset2.tabels(0).rows(j)(3).tostring 'Entry exists in both ds's
exit for
Else
Take action to mark as changed
end if
next
next
As of yet, this does not produce the results I am looking for, and I
can't figure it out. Something wrong with the loop??? I know this is
not very elegant, but if someone could suggest a better way, I am all
ears!!!! Maybe dataset1.Merge(dataset2)????
Thanks for the Help!!!!
(I apologize for the crossposting)
Frank
Developing an app where the user fills out a sometimes quite lengthy
form of chkboxes, txtboxes, radbtns, etc. User responses are saved to
a mySql db, which the user can later edit.
When the user chooses to edit, I pull the responses from the db, toss
them in a dataset, check the checks, fill the txtboxes, etc.,etc.
The user then adds, deletes, or changes entries as needed and clicks
the Save Changes button. Here is where the fun begins....
I have to keep track of changes made to the saved form and mark those
items that have 'changed' as well as inserting the new editions to the
database.
My logic so far is this: When they click the Save Changes btn, I throw
all the responses into a new dataset and then compare the original
dataset to the new dataset.
Basically, if an anwer exits in dataset 1 (the original), but not in
dataset 2, that anwer was changed. Conversely, if an answer exits in
dataset 2 (the edited version), but not in dataset1, that answer was
added.
My question is: How can I best compare the 2 datasets, see what has
changed and update the db accordingly, while being minfull that NO
entries can be deleted, only marked as changed or added.
Here is some code that I have tried (from my head):
for i = 0 to dataset1.tables(0).count -1
for j = 0 to dataset2.tables(0).count - 1
if dataset1.tabels(0).rows(i)(3).tostring =
dataset2.tabels(0).rows(j)(3).tostring 'Entry exists in both ds's
exit for
Else
Take action to mark as changed
end if
next
next
As of yet, this does not produce the results I am looking for, and I
can't figure it out. Something wrong with the loop??? I know this is
not very elegant, but if someone could suggest a better way, I am all
ears!!!! Maybe dataset1.Merge(dataset2)????
Thanks for the Help!!!!
(I apologize for the crossposting)
Frank