Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Help with Linq To Dataset

Posted on 2014-10-24
2
Medium Priority
?
192 Views
Last Modified: 2016-02-15
Experts, I am having trouble getting a column from my datatable using a linq query. I fill the datatable from an SQL query. The column is an integer type. I can use the linq queries just fine with string columns but cannot get it to work on integers.

Please Help...

Column Name is "rWidth".
Dim query as iEnumerable(Of Integer)
Dim iList as New List(Of Integer)

query = From w in ds.tables("dtRibbon")
               Select w.Field(Of Integer)("rWidth")
               Distinct

iList = query.ToList

Open in new window

0
Comment
Question by:Basicfarmer
[X]
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
2 Comments
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 2000 total points
ID: 40403564
You are missing two constructs:
1) AsEnumerable. You can't query against the DataTable's Rows collection, since DataRowCollection doesn't implement IEnumerable<T>.
2) Distinct is a method call.
Modified query is shown below
query = (From w in ds.tables("dtRibbon").AsEnumerable()
               Select w.Field(Of Integer)("rWidth"))
               .Distinct()

Open in new window

0
 

Author Closing Comment

by:Basicfarmer
ID: 40407073
Thanks for the solution. Exactly what I was missing...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

715 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