Click to See Complete Forum and Search --> : Help!!!!!


MathewJose
April 10th, 2007, 08:26 AM
Hello everybody,

i have a datasource with 2 datatables.
i need to join both the datatables into one and bind it, inorder to display it in a datagridview in C#.Net windows application.

Anyone has got any idea how to join 2 datatables and make it one?
I've heard that using JoinView its possible.Anybody has gota samplecode ??



Plz help me out!!

Talikag
April 10th, 2007, 09:54 AM
Add an ID column to both tables, and then try this query:

//One of the following will probably work:
SELECT FROM Table1.*,Table2.* WHERE Table1.ID = Table2.ID;
SELECT * FROM Table1,Table2 WHERE Table1.ID = Table2.ID;

You can use the JOIN key word to do that, too. More information here: http://www.w3schools.com/sql/sql_join.asp

TheCPUWizard
April 10th, 2007, 09:57 AM
Depends on exactly what you mean. If you are talking about something like having a Sales2006 and Sales2007 with the same schema and you at to display all (or some filtered version) that contains sales from both tables, then UNION is the SQL keyword you are looking for.

Join is used to combine columns from multiple sources, but can not be used to make multiple tables look like one long table....

MathewJose
April 10th, 2007, 09:07 PM
Thank u friends for the tips.

Actually, one datatable contains data copied from an excel sheet and the other one contains a set of names populated from db.
I need to enter excel sheet data against each name.For that ,i have copied excel sheet data to a datatable and db data to another datatable.

I thought of joining both to make one.Will it work?Anyother alternatives to combine both data to make it into a single datatable?
Plz help...