hey guys,
I'm a little new when it comes to the ASP environment, and I need a
little help...
Does anyone know how to combine two separate datatables, and get them
to display one after the other on a datagrid? I am currently trying to
use viewstate.Add, to get both of them together but that's just not
working, and I don't see a viewstate.merge or join or anything.
Has anyone ever found a way to work around this? Or is there something
I am overlooking?
Thanks! 7 2199
1. I would recommend doing it on database side if possible.
Use "UNION" in SQL to combine 2 SELECTs
2. If #1 is not an option, all I can come up with is manually adding rows
from one DataTable object to another DataTable object and then bind your
grid to that DataTable.
Like
DataTable dt1, dt2;
dt1 = GetData("...sql...");
dt2 = GetData("...sql...");
foreach(DataRow r in dt2.Rows)
{
DataRow newRow = dt1.NewRow();
newRow.ItemArray = r.ItemArray;
dt1.Rows.Add(newRow);
}
George.
<Jo*****@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
hey guys,
I'm a little new when it comes to the ASP environment, and I need a
little help...
Does anyone know how to combine two separate datatables, and get them
to display one after the other on a datagrid? I am currently trying to
use viewstate.Add, to get both of them together but that's just not
working, and I don't see a viewstate.merge or join or anything.
Has anyone ever found a way to work around this? Or is there something
I am overlooking?
Thanks!
<Jo*****@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
hey guys,
I'm a little new when it comes to the ASP environment, and I need a
little help...
Does anyone know how to combine two separate datatables, and get them
to display one after the other on a datagrid? I am currently trying to
use viewstate.Add, to get both of them together but that's just not
working, and I don't see a viewstate.merge or join or anything.
Has anyone ever found a way to work around this? Or is there something
I am overlooking?
Thanks!
you might also look into dataset merge as long as you have a common primary
key defined. You would create a data set with the first table and then merge
the second table into the dataset.
I agree w/ George... and doing it on the DB side is the better
option. If using "UNION", be careful... you probably want "UNION ALL"
instead.
On May 12, 11:29 pm, GroupReader <newsgroups...@hotmail.comwrote:
I agree w/ George... and doing it on the DB side is the better
option. If using "UNION", be careful... you probably want "UNION ALL"
instead.
The union would not work unfortunately because it is using the same
database.
It is completely dependant on what the user actually inputs into the
screen as to what I am adding to the grid.
Basically there are 2 distinct types on data for the grid, and they
can't be mixed up. So I was just going to create separate datatables
and then merge them together.
It seems like I will have to just try the looping or the merge
method , because I don't think that it will work any other way
really.
Thanks guys!
DataSet.Merge works well.
---------------
IF you have 2 seperate tables (in your dataset) .
Like
ds.Employee
ds.Dept
-----------
It works well on one table, but you have different PK's (as mentioned)
like
ds.Employee
ds.Employee
(perhaps the first one has full time employees, and the second
one has part time employees)
EmployeeDS ds1 = new EmployeeDS();
//populate ds1 with full time emps.
EmployeeDS ds2 = new EmployeeDS();
//populate ds2 with parttime emps.
EmployeeDS dsmerged = ds1.Merge( ?? ds2 //multi overloads here) ;
...
Merging "the same rows based on the PK" is a totally different story, and
this permutation doesn't play nice.
<Jo*****@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
hey guys,
I'm a little new when it comes to the ASP environment, and I need a
little help...
Does anyone know how to combine two separate datatables, and get them
to display one after the other on a datagrid? I am currently trying to
use viewstate.Add, to get both of them together but that's just not
working, and I don't see a viewstate.merge or join or anything.
Has anyone ever found a way to work around this? Or is there something
I am overlooking?
Thanks!
"vMike" <Mi****************@noYandZ.geZwaYrrenZ.comwrote in message
news:DT**************@bignews7.bellsouth.net...
>
<Jo*****@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
>hey guys, I'm a little new when it comes to the ASP environment, and I need a little help... Does anyone know how to combine two separate datatables, and get them to display one after the other on a datagrid? I am currently trying to use viewstate.Add, to get both of them together but that's just not working, and I don't see a viewstate.merge or join or anything. Has anyone ever found a way to work around this? Or is there something I am overlooking?
Thanks!
you might also look into dataset merge as long as you have a common
primary key defined. You would create a data set with the first table and
then merge the second table into the dataset.
The more I think of it you can merge two or more tables as a union or as a
left join, depending on the MissingSchemaAction. The merge function will
union if the two tables have identical structure but if there are any
duplicate primary keys it will fail. If you want to join you would need
identical primary keys in both tables and use the msa.add.
Mike
"vMike" <Mi****************@noYandZ.geZwaYrrenZ.comwrote in message
news:Yk****************@bignews4.bellsouth.net...
>
"vMike" <Mi****************@noYandZ.geZwaYrrenZ.comwrote in message
news:DT**************@bignews7.bellsouth.net...
>> <Jo*****@gmail.comwrote in message news:11**********************@q75g2000hsh.googleg roups.com...
>>hey guys, I'm a little new when it comes to the ASP environment, and I need a little help... Does anyone know how to combine two separate datatables, and get them to display one after the other on a datagrid? I am currently trying to use viewstate.Add, to get both of them together but that's just not working, and I don't see a viewstate.merge or join or anything. Has anyone ever found a way to work around this? Or is there something I am overlooking?
Thanks!
you might also look into dataset merge as long as you have a common primary key defined. You would create a data set with the first table and then merge the second table into the dataset.
The more I think of it you can merge two or more tables as a union or as a
left join, depending on the MissingSchemaAction. The merge function will
union if the two tables have identical structure but if there are any
duplicate primary keys it will fail. If you want to join you would need
identical primary keys in both tables and use the msa.add.
Mike
I got the fail backwards. The left join will fail if there are more then one
identical primary keys in the left join table. Merge will fail for one to
many, has to be one to one. The union will ignore the identical key. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jade |
last post by:
Hi,
I just wanted to ask a quick question regarding datasets.
I am creating 3 tables using a dataadapter. what i want
to know is that is the relationship created between these
datatables...
|
by: Job Lot |
last post by:
Is there anyway of Joining two or more DataTable with similar structure?
I have three DataTables with following structures
Data, AmountB/F, Repayments, InterestCharged and AmountC/F
i want...
|
by: Z D |
last post by:
Hello,
I'm currently using Remoting (HTTP/Binary) to remote a simple object.
Everything is working fine except for one function that returns an arraylist
of datatables.
When I call this...
|
by: sal |
last post by:
Greets, All
Converting array formula to work with datatables/dataset tia sal
I finally completed a formula I was working on, see working code below.
I would like to change this code so it...
|
by: Frank |
last post by:
Hello All,
I am working on a vb.net app where I need to compare to 2 datatables
and determine if a string exists in one or both. The first dt is
filled from the db. A form is loaded and the...
|
by: cj |
last post by:
I've used datatables and datasets before. Datasets being able to hold
more than one table and datatables being only one table. My mind keeps
coming up with recordsets. I can't remember how they...
|
by: bbdobuddy |
last post by:
Hi,
I have two datatables that I want to left outer join and then do some
queries on but I having a hard time figuring out how to join the datatables
together. One of the datatables comes from...
|
by: StefanPienaar |
last post by:
Hi Guys
Is there any way in c# (or vb.net) to extract a datatable of data from a dataset with multiple datatables which has relationships set up (containing combined data from the datatables)?
...
|
by: =?Utf-8?B?QVZM?= |
last post by:
Hi,
Ive two data tables..I need to perform a join on these datatables..
and fetch the data..I need to do it programaticlaly..
How can I acheive it...any sample code wpuld be of great help..
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
| |