Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

LINQ query to datatable

Posted on 2009-06-29
2
1,420 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

837 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