Making 2 datasets to one

J

Jens

Hi

IS there a better way to join 2 datasets into one, than
adding rows from datset1 to dataset2 through a loop?
thanks in advance.
I need this to show the common result in a datagrid.

Jens...
 
C

Cor Ligthert

Jens,

A dataset has no rows, therefore can you explain it a little bit better. Are
you talking about 2 separated datasets with one table or about one dataset
with 2 tables.

I think that in the second situation (while it is only used for showing) I
would choose for the Join, in the first it is impossible to do. In the
second case there are more possibilities however is it in my opinion very
important why you want to do it.

In both situations is it important if you only want that datatable for
showing or as well for updating.

Cor
 
J

Jens

Cor Ligthert said:
Jens,

A dataset has no rows, therefore can you explain it a little bit better.
Are you talking about 2 separated datasets with one table or about one
dataset with 2 tables.

I think that in the second situation (while it is only used for showing) I
would choose for the Join, in the first it is impossible to do. In the
second case there are more possibilities however is it in my opinion very
important why you want to do it.

In both situations is it important if you only want that datatable for
showing or as well for updating.

Cor

Cor

My customer wants 2 tables, even the dataschema is the same.
My App is a product modulations/configuration type, where users can select
products in 2 ways,
either by simply adding a qty in a cell in the datagrid(dataset1) SQL pick
data from Table1, or the user can use a configuration tool, where clicks on
5-6 comboboxes, checkboxes, and by help of some code for the business
rules, then create dataset2, SQL pick these data from Table2
In both cases it it only for showing the result.

Jens
 
J

Jens

Cor Ligthert said:
Jens,

Did you already try this one (In never did it with parent-child)
http://msdn.microsoft.com/library/d...temdatadatacolumncollectionclassaddtopic5.asp

The expression, the link is on the page
http://msdn.microsoft.com/library/d...fsystemdatadatacolumnclassexpressiontopic.asp

And than this one
PARENT/CHILD RELATION REFERENCING

I hope this helps,

Cor

Cor
I am using a lot Parent/Child datarelations in my app, but this could not be
used in this specific case.
I will use my loop addding row to a datatable instead.
Thx anyway
Jens
 
A

Andrzej Kaczmarczyk

Cor
I am using a lot Parent/Child datarelations in my app, but this could not
be used in this specific case.
I will use my loop addding row to a datatable instead.
Thx anyway
Jens

(you still didn't explained it clear)
I assume you have TWO datasets with ONE table each and that those tables are
identical.
This will work equally well if you have ONE dataset with TWO tables that are
identical but name.
you want to join them.
You should use the Merge() method, read on in MSDN about it, you can
configure it pretty well, like skipping keys, preserving changes etc...
The Merge() method works equally well on table and dataset level

// setup
DataSet ds1 = new DataSet();
DataSet ds2 = new DataSet();
DataTable tb1 = new DataTable("Table");
DataTable tb2;
DataColumn col = new DataColumn("Column", typeof(int));
tb1.Columns.Add(col);
ds1.Tables.Add(tb1);
tb2 = tb1.Copy();
// (notice that the copy above is just to copy the structure, and later on
the tables are filled with different data)
ds2.Tables.Add(tb2);
// data
tb1.Rows.Add(10);
tb2.Rows.Add(11);
// join tables
tb1.Merge(tb2);


CUIN Kaczy
 
J

Jens

// setup
DataSet ds1 = new DataSet();
DataSet ds2 = new DataSet();
DataTable tb1 = new DataTable("Table");
DataTable tb2;
DataColumn col = new DataColumn("Column", typeof(int));
tb1.Columns.Add(col);
ds1.Tables.Add(tb1);
tb2 = tb1.Copy();
// (notice that the copy above is just to copy the structure, and later on
the tables are filled with different data)
ds2.Tables.Add(tb2);
// data
tb1.Rows.Add(10);
tb2.Rows.Add(11);
// join tables
tb1.Merge(tb2);


CUIN Kaczy

Thx Andrzej

To make it clear I have TWO datasets with ONE table each, and those tables
are
identical.(Sorry, English is not my born language).
And I want all data to be joined so we can see them in ONE grid after the
configuration part has finished.
I have been to merging datasets, but that doesn't join the data into one
table.
Now I understand your explanation using the datatable merge instead, this
works as I wanted it.
Thanks a lot for your input

Jens...
 
C

Cor Ligthert

Jens,
identical.(Sorry, English is not my born language).

Nice to say that from you while in this thread are beside you (Danish) only
a Polak and a Dutchman active. Most of us in these newsgroup try to
communicate and use the layer English, however are not so interested in
grammatical issues.

:))

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top