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 4 3691
Frank
This is the exact same situation I am in. I have an app that lets the user
search for a specific record and then update just one of the corresponding
columns. With two buttons I can't access the original dataset through normal
coding. I've yet to find away around this except for the unsucessful
comparing of the 2 datasets. If you have any luck with yours let me know and
I'll do the same.
Thanks
"Cor Ligthert [MVP]" wrote: Frank,
You are comparing two datatables which makes a big difference with comparing two datasets.
I try first to do this kind of things using the datarowcollection.find (giving the row) or the dataview.find (giving the index of the row)
http://msdn2.microsoft.com/en-us/lib...tion.find.aspx
http://msdn.microsoft.com/library/de...sfindtopic.asp
I hope this helps,
Cor
Neo,
I will keep you posted on progress. At this point, my method works,
but only if the user changes more than 1 item. For some reason, it
fails if there is only 1 change. I think the route I am going to
attempt next is along the lines of what Cor suggested: Search for
matching datarows. Something like this:
dim dr as datarow
dim drChg as datarow
for each dr in dt1
drChg = Dt2.Rows.Find(dr.Item(Some Criteria))
If drChg Is Nothing Then
dt3t.Rows.Add(dr)
Else
...
End If
next
(Or something thereabouts...)
Will let you know how it works..
On Wed, 25 Jan 2006 08:10:04 -0800, Neo
<Ne*@discussions.microsoft.com> wrote: Frank This is the exact same situation I am in. I have an app that lets the user search for a specific record and then update just one of the corresponding columns. With two buttons I can't access the original dataset through normal coding. I've yet to find away around this except for the unsucessful comparing of the 2 datasets. If you have any luck with yours let me know and I'll do the same. Thanks
"Cor Ligthert [MVP]" wrote:
Frank,
You are comparing two datatables which makes a big difference with comparing two datasets.
I try first to do this kind of things using the datarowcollection.find (giving the row) or the dataview.find (giving the index of the row)
http://msdn2.microsoft.com/en-us/lib...tion.find.aspx
http://msdn.microsoft.com/library/de...sfindtopic.asp
I hope this helps,
Cor
Cor,
Thanks for the help. Think I will take your very sage advice and try
something similar to what you suggest.
Thanks again!!
On Wed, 25 Jan 2006 09:16:41 +0100, "Cor Ligthert [MVP]"
<no************@planet.nl> wrote: Frank,
You are comparing two datatables which makes a big difference with comparing two datasets.
I try first to do this kind of things using the datarowcollection.find (giving the row) or the dataview.find (giving the index of the row)
http://msdn2.microsoft.com/en-us/lib...tion.find.aspx
http://msdn.microsoft.com/library/de...sfindtopic.asp
I hope this helps,
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Eric |
last post by:
Hello,
I am trying to write a webservice to compare 2 datasets, one recieved
from a client, and the other taken from a database on the webserver.
Sofar, I have had little success in...
|
by: Alpha |
last post by:
I have a small Window application and through out the different forms I
create a different dataset. At the begining I used the Tools to drag and
drop the SqlDataAdapter, connection and dataset...
|
by: Elliot M. Rodriguez |
last post by:
I can accomplish this relatively easily but inefficiently, and it seems like
a hack, but I cant think of a better workaround. Hopefully someone else here
can.
My task is to perform an update on...
|
by: Will Lastname |
last post by:
In one of the applications that I'm working on I have 2 sets of
functions that build different datasets.
Imagine 4 columns in a datagrid. Inside those 4 columns I have nested
datalists. Two of...
|
by: GaryDean |
last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much
in answers so I'm reposting some questions posted by some of the programmers
here in our organization that never got...
|
by: S.Tedeschi |
last post by:
Hi all;
as posted some days ago, I'm converting an on-line app; I used to
heavily rely on strongly-typed DataSets directly dropped onto pages,
and so viewed by code(-behind) as well. In the next...
|
by: Franck |
last post by:
how come unchanged always true even if data changed
This code come from my saving button:
============================================
DataSet ds1 = new DataSet();
DataSet ds2 = new...
|
by: BillE |
last post by:
I'm trying to decide if it is better to use typed datasets or business
objects, so I would appreciate any thoughts from someone with more
experience.
When I use a business object to populate a...
|
by: gardnern |
last post by:
We have X number of data sets, of Y length each.
For example...
Small, Medium, Large
and
Red, Green, Blue, Yellow
We need to generate a list of all possibilities
Small Red
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |