Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8714223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:32:37+00:00 2026-06-13T05:32:37+00:00

is it possible to use filter expression to select some columns? something like select

  • 0

is it possible to use filter expression to select some columns?
something like select a,b,c from table in sql

here is what i am trying to do

 Dim rows() As DataRow = bookedorders.Select("a,b,c")   'select columns a b c only, i know its wrong
        Dim zzz As DataTable = rows.CopyToDataTable

so is it possible to use the Datatable.Select to select columns and the use a condition like sql WHERE a=1

my linq try was

Dim q = From r In bookedorders.AsEnumerable Select r.Field(Of Integer)("a") And r.Field(Of String)("b") And r.Field(Of String)("c") And r.Field(Of Integer)("d")
        For Each m In q
            zzz.Rows.Add(m)
        Next

which doesnt seem to work, it says that the number of items in array is longer than the datatable!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:32:41+00:00Added an answer on June 13, 2026 at 5:32 am

    DataTable.Select allows you to specify a filter as a String:

    bookedorders.Select("a = 1")
    

    You cannot specify columns to be extracted because that would break type structure, as it is expected to return same DataRow as you originally had. If you were to return only specific columns, you would need another DataTable to contain them.

    Assuming this functionality existed, limiting number of returned columns is not practical, because you already have your DataRows filled with data, unlike select a,b,c from table, where you can reduce network bandwidth and speed up query performance by specifying only certain columns to be extracted from a database.

    If you want to use LINQ, you can do it like this:

    From r In bookedorders Select a=r.Field(Of Integer)("a"), b=r.Field(Of String)("b"), c=r.Field(Of String)("c"), d=r.Field(Of Integer)("d")
    

    Note that you cannot use results of this query to directly .Add rows to a DataTable, because returned enumeration is not of type DataRow. If you need it badly, here is an implementation on MSDN.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to use the Select Expert to generate a filter so my
Is this possible to use Ajax.Beginform with update target inside of ajax form. like
Is it possible to use [RequireHttps] filter with a different port other than 443?
Is it possible to use SQL Server Profiler 2008 to catch which program, run
Is possible to convert a Predicate<T> to Expression<Func<T, bool>> in some way? I would
Is it possible to use Zend_Filter_Input as a generic input filter? I want to
Is it possible to use trans filter or path function dynamically?With variables as parameters?
Is it possible to use a profile based filter in your web.xml ? For
Is it possible to use tabs to act as a filter for a list
Is it possible to load a django template tag/filter to use as a function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.