473,396 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

LINQ to DataTable

112 100+
hi,

I am trying to join two datatables using LINQ. I am unable to use .CopyToDataTable in my code. I have added System.Data.DataSetExtensions.dll. It gives me the error, 'CopyToDataTable' is not a member of 'System.Collections.Generic.IEnumerable(Of <anonymous type>)'.

I have searched online a lot about this. The solution was to add the dll which I did but still I get the error.

Also there are few suggestions for LINQ to datatable which are very huge. I would like to keep it simple. I am not sure, why the CopyToDataTable would not work for me.

here is my code, thank you for your time.

Expand|Select|Wrap|Line Numbers
  1.   Dim dt2 As New DataTable
  2.             dt2.Load(dr2)
  3.             Dim dt3 As New DataTable
  4.             dt3.Load(dr3)
  5.           Dim ds As New DataSet
  6.  
  7.  
  8.  
  9.          Dim joinquery = From t1 In dt2.AsEnumerable() Join t2 In dt3.AsEnumerable() _
  10.                     On t1.Field(Of Decimal)("CLASS_NUMBER") Equals t2.Field(Of Decimal)("CLASS_NUMBER") _
  11.                     Select New With _
  12.                       {Key .CLASS_NUMBER = t1.Field(Of Decimal)("CLASS_NUMBER"), _
  13.                        Key .FACULTY_START_DT = t2.Field(Of DateTime)("FACULTY_START_DT"), _
  14.                        Key .FACULTY_END_DT = t2.Field(Of DateTime)("FACULTY_END_DT"), _
  15.                        }
  16.  
  17.      ds = joinquery
  18.  
  19.  
  20.             NewDg.DataSource = ds
  21.             NewDg.DataBind()
Jul 6 '11 #1
0 1495

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: =?Utf-8?B?dHZpbg==?= | last post by:
Hi everybody i have a datatable, i want to select distinct value from datatable and not database. so is there any method that can provide this query: Select DISTINCT from DataTable please help...
1
by: Kevin S. Goff | last post by:
Someone asked me how I would do the following....suppose you have two ADO.NET datatables, and you want to do the equivalent of SELECT Table1.*, Table2.* (in other words, do a linq query that...
0
by: =?ISO-8859-1?Q?S=F8ren_Reinke?= | last post by:
Hi there. I am trying to get to know LINQ in combination with a bindingsource and a datagridview. In the framework we have at work we have created a usercontrol to do filtering via...
1
by: szwejk | last post by:
Hi! How to get result od dataTable from Linq query? I have typied DataSet and I want to join couple of tables. And I have a problem with change this result to DataTable type. (I don't want to...
0
by: Ronald S. Cook | last post by:
Using LINQ, I can bind my IEnumerable to my ComboBox no problem. However, in the past it would be a DataTable that I could insert a new row (e.g. "(Please select...)") and then sort it with a...
0
by: ranganadh | last post by:
Dear Group members, I am new to LINQ, pls help on the deeling with huge amount of data with the C# stand Alone application. I have two file, which contains more then 2 lacs lines in every...
2
by: Ronald S. Cook | last post by:
I have a DataTable that looks like this: Id Value 123 4.0 123 5.0 234 1.0 345 2.0 345 3.0 I want to end up with (probably a new DataTable) that contains the sum of
0
by: Andy B | last post by:
Hi... I have this DataTable: StockContract.Dictionary. I need a linq to DataTable query that will select all rows where the "Word" column values match the WordTextBox.Text value. I am running...
1
by: Tony Johansson | last post by:
Hello!! I just wonder if you have any examples of creating a LINQ query between a DataSet and an Xml file. //Tony
1
by: Dean Slindee | last post by:
VS2008, .NetFramework 3.5 SP1: I have built a LINQ data access layer project. When the LINQ data context was built over an existing SQL2005 database, the connection string for that database was...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.