SolvedPrivate

VB Linq to straight VB

Posted on 2014-02-28
4
41 Views
Last Modified: 2016-02-10
Stupid question of the day...

How can I make the following linq statement into a straight vb statement

I'd like the results to be a datatable

            Dim Query = _
            (From Region In dataset1.Tables(0) _
             Where Region.Field(Of String)("Region") <> "" _
                    Select Region.Field(Of String)("Region") _
             ).Distinct().OrderBy(Function(item) item).ToList

Open in new window

0
Comment
Question by:lrbrister
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39894758
Do you want to convert it to ADO.NET code to populate datatable or do you want to convert the result of this LINQ query into a datatable?

It is currently giving you a list of string which you can loop through.
0
 

Author Comment

by:lrbrister
ID: 39894768
CodeCruiser

The end goal is something that a rabid "anti-linq" person could use.

You've been answering my questions for quite some time...I don't care one way or the other personally.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39894944
From your "anti-linq" usage, I am assuming you want to get rid of the query.

If I remember correctly, you know how to use a tableadapter to populate a datatable so its a matter of constructing a sql query like below

SELECT DISTINCT Region From Regions Where Region Is Not Null And Len(Region) > 0 Order By Region
0
 

Author Closing Comment

by:lrbrister
ID: 39894972
Thanks.

I wrote the linq query with some EE help.

The other team members hate linq for some reason and want it out.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 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

19 Experts available now in Live!

Get 1:1 Help Now