Update Dataset

I am using C# in .NET
i have a dataset called changedDS with some rows. (primary key for this is id and date)
And i have another dataset called UpdateDS with many rows from a table (single table with primary key id and date). (And i am using Commandbuilder for this dataset so that i can update the underlying table)
Now i need to update the UpdateDS with changedDS data where primary key fields match.
If you can provide sample code that would be really great!

Thanks
CMT MichiganAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

grayeCommented:
It sounds like you need to do a "join" operation between the two tables....  Take a look at the following link to see if I'm on the right track.

The C# Join Helper Class is at http://support.microsoft.com/default.aspx?scid=kb;en-us;326080

I presume that the schema is not the same between the two DataTables?   And that after you've performed the join you will interate thru the rows and copy the relevant columns?....   or are the schemas identical, and you could just replace the row?

As a matter of semantics, do you really have two different DataSets or do you have two different DataTables in one DataSet.   Currently, the ability to create relationships between DataTables is restricted to tables within the same DataSet.
0
CMT MichiganAuthor Commented:
Hi,

Thanks for your reply.
The Schema is same. I have two diffterent Datasets. (Why am i doing this?). Because i am displaying the data from a SP using temp table (becuase user wants to see data in different ways, for example i have data in day level inthe databse, some times they want to see data in week level or month level for this i am summing up and displaying on the grid). So i can not update this data directly. So i have another dataset at day level just for update. So i thought i can grab the modified rows from the grid and match with the other dataset (the one i populated for update) and update.
0
grayeCommented:
Well, you still could add the existing DataTable from one DataSet to the other DataSet....  it's just one line of code:

     ds1.Tables.Add(ds2.Tables["TableName"]);

After that you could use the join helper class to essentially do an SQL join on the two tables.   Once the join in completed, you'd just loop thru the rows and copy the column data...
0
CMT MichiganAuthor Commented:
i figured it a way to do it. Whatever the changes on the grid i am populating to a dataset using getchanges and rowstatus
and then i am looping through this Dataset and creating a Datarow(on the dataset i created for update) using the Dataset select , then updating the values.

Thanks
0
DarthModCommented:
PAQed with points refunded (150)

DarthMod
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.