Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / February 2005

Tip: Looking for answers? Try searching our database.

Select into new Datatable from Datatables

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Daniel - 23 Feb 2005 16:14 GMT
Hi
I have searched vbcity and the internet for a solution for my question
but with no luck. But I am sure it must be simple to accomplish?

I have to Datatables, DT1 and DT2, already populated from database.

What I want to do is to select data from two (or more) datatables (in
memory) into a new datatable.

I have solved the problem constructing a new SQL query (from the info
in the two tables) and sending it to the database but I want to save
the trip to the database since all the data is already in memory in
the two tables.

I have also solved it looping through the datatables and populating a
new datatable row by row, item by item, but that seems unnecessary and
slow also.

I want to do a JOIN from these two tables and put the results into a
new Datatable:

Something like this:
DT3 = SELECT DT1.col1, DT2.col2 FROM DT1, DT2 WHERE DT1.col1 =
DT2.col1 AND DT2.col2 > 10

I have looked into the Dataset and Datatable objects with no luck. How
do I use the datatables/dataset as a datasource to query?

Thanks!

Daniel
"Andrew Conrad" - 24 Feb 2005 17:52 GMT
Create a DataRelation between the two table and navigate between the two
tables:

 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconnavigatingrelationshipbetweentwotables.asp

 For 1 to many and many to many relationships this is not precisely the
same as a join result since the parent side is not denormalized, but
equivalent for most scenarios.

Andrew Conrad
Microsoft Corp

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.