Solved

Query results to data table

Posted on 2009-06-28
3
310 Views
Last Modified: 2013-11-11
I need to build a table with the results of different LINQ queries.  I was trying to do this with a data table but now sure of the syntax.  An example of what I'm trying to do is below.
After I add all the columns and create all the other LINQ queries, How do I add/update the data table with the results? Or is there a better way then using a data table? Was I build the table and create calculate columns the end results will end up in an excel spreadsheet.
Using VB 2008  framework 3.5.
Thanks


Dim ResultsTable as DataTable

Dim dc As New dcDSSDataContext
 

Dim TMADODList = From TMA In dc.vwCurrentTMA _

     Select TMA.DOD

Dim InterChgDODList = From IC In dc.datInterchangeableDOD _

      Select IC.DOD
 

Dim DODList = TMADODList.Union(InterChgDODList )

DODList = DODList.Distinct
 

ResultsTable = New DataTable("Results")
 

ResultsTable.Columns.Add("DOD", GetType(String))

ResultsTable.Columns.Add("Location", GetType(String))

'Other columns added here

Open in new window

0
Comment
Question by:MadIce
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
Sreedhar Vengala earned 500 total points
Comment Utility
Think below will guide you in right way:

Creating a DataTable From a Query (LINQ to DataSet) ( http://msdn.microsoft.com/en-us/library/bb386921.aspx  )
0
 
LVL 9

Expert Comment

by:Sreedhar Vengala
Comment Utility
0
 

Author Comment

by:MadIce
Comment Utility
I get CopyToDataTable() is not a member of System.Liq.IQueryable(Of String) error. Do I need to add a reference?
I got the datatable to add new rows with the following
For Each DOD in DODList
    ResultsTable.Rows.Add(New Object() {DOD})
Next

But how do I update Columns with the results of a different LINQ query?  I want to update the second Query?
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now