Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 16, 2012 05:21 AM by BlueCloud
Jul 11, 2012 04:59 PM|LINK
can any1 help me on this?
I have three datatables DT1,DT2,DT3.
Iam populating data from threee different database tables into these tables.
How can i join these tables and run a query with some condition.All the three tables have Some relation.
Ex: primary Key DT1 wl be Foreign key in DT2....so on....I just want to work on these tables instead of again going to Database.
Jul 11, 2012 05:03 PM|LINK
Depends on what your after but you could use INNER JOIN (although there are different types of JOIN) to join the IDs from each table i.e. the primary key from your main table to join with the Foreign Key on the secondary table and then return rows accordingly.
For more info on JOINS http://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins
Jul 11, 2012 05:06 PM|LINK
Thanks for reply, i dont want to know about joins, I just want to know
how can i Join the tables without going to database again.
I just want to do join on the resulted data which is stored in Datatables during runtime
select * from DATABASE1.dbo.DT1 dt1
join DATABASE2.dbo.DT2 dt2
on dt1.item_no = dt2.item_no
join DATABASE3.dbo.DT3 dt3
on dt1.item_no = dt3.item_no
Jul 11, 2012 05:12 PM|LINK
Thanks for reply.
Can you just eloborate the above query plz...
I just want to work on the resulted data tables instead of going to database again.Can you plz help me on this?
Jul 16, 2012 01:08 AM|LINK
Hi, you can get data with the SQL command, and then store them in ViewState. For example:
System.Data.DataTable MyTable = new System.Data.DataTable();
// You codes to get data from database here.
ViewState["myTable"] = MyTable;
Jul 16, 2012 03:49 AM|LINK
Plz check the following link
Jul 16, 2012 05:03 AM|LINK
select * from DT1 inner join DT2 inner join DT3 on Primarykeycolumname.DT1=foreignkeyofcolumnnane.DT2 on foreignkeycolumnname.DT3
Jul 16, 2012 05:21 AM|LINK
I think you want to join two or more datatable objects without querying database.
Have a look up following link, hope it will help.