473,395 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to update dataset.Tables["tab1"] from records in dataset.Tables["tab2"]?

Hi.

How do i "bulk update" data rows on a dataset table from another one
DataTable?

i have a dataset ds1 with a table "Groups" and a table "newgroupdata"
and i want to update the records in ds1.Tables["Groups"] from the data
in ds1.Tables["newgroupdata"].
Additional i want to insert groups wich are not already in "Groups"
too.

Is this possible.

At the moment i loop thru "newgroupdata" and do a

DataRow[] foundRows = ds1.Tables["Groups"].Select( "Group = '" +
findgroup + "'", "", DataViewRowState.Added );

if(0==foundRows.Length)
{
// Add group to "Groups"
}
else
{
// Update foundRows
}

running this on a table with multiple thousand group records is
horrable slow.
I fear this can only be done in a fast and efficient way using a
database server.

Jan 12 '06 #1
1 1764
If you can, establish the Group column as the PrimaryKey for both
tables. Then you can use Find rather than Select, which is much faster.

If you set the PrimaryKey property for both tables, and if your table
columns are in the same order, you should be able to reduce your code
to something like this:

DataTable groups = ds1.Table["Groups"];
groups.BeginLoadData();
foreach (DataRow row in newgroupdata.Rows)
{
object[] values = row.ItemArray;
groups.LoadDataRow(values, false);
}
groups.EndLoadData();

Would that work for you?
}

Jan 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: rkhurana | last post by:
Hi I am writing a JSF application that uses some third party charts. While I can see the chart but the javascript that is supposed to calla function to update chart periodically has a problem. It...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.