Solved

LINQ query to datatable

Posted on 2009-06-29
2
1,416 Views
Last Modified: 2013-11-11
I'm using VB 2008
I want to do some Linq queries and the result convert to datatable to use in a datagridview.
If I dothe Option 1 (see the code) it works well, but I have to declare the Linq Query as a System.Data.EnumerableRowCollection(Of ..)

If I declare the Linq query as    IEnumerable it do the query well but then I can't convert it to datatable.      
''Option 1

            Dim Comp053 As System.Data.EnumerableRowCollection(Of LOGDataSet.MovRow)

            Dim tabMovFac As LOGDataSet.MovDataTable

 

            Comp053 = From f In tabMovFac.AsEnumerable _

                       Where (f.TipoFactura <> "I")

            

 

	    Dim taulaComp053 As DataTable

            taulaComp053 = New DataTable

 

            If Comp053.Count > 0 Then

                taulaComp053 = Comp053.AsEnumerable.CopyToDataTable

            End If

Open in new window

0
Comment
Question by:cpx_Support
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 24735020
I usually code my own methods naming them such as ShredContacts etc. Within these methods, i iterate through the query and manually create datatable. It also helps with things like adding the name of the emp who created the client rather than the ID or the object.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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

11 Experts available now in Live!

Get 1:1 Help Now