what is the easiest way to select top 20 rows from a datatable ?

Discussion in 'ASP .Net' started by Ersin Gençtürk, May 6, 2005.

  1. I can't find a expression for table views did i missed something ?
     
    Ersin Gençtürk, May 6, 2005
    #1
    1. Advertising

  2. SELECT TOP 20
    *
    FROM TBL_TABLENAMEHERE

    Will do what you asked.

    Deasun

    "Ersin Gençtürk" wrote:

    > I can't find a expression for table views did i missed something ?
    >
    >
    >
     
    =?Utf-8?B?RGVhc3Vu?=, May 6, 2005
    #2
    1. Advertising

  3. Ersin Gençtürk

    Mark Rae Guest

    "Deasun" <> wrote in message
    news:D...

    > SELECT TOP 20
    > *
    > FROM TBL_TABLENAMEHERE
    >
    > Will do what you asked.


    Assuming the RDBMS supports the "TOP" reserved word...
     
    Mark Rae, May 6, 2005
    #3
  4. I mean selecting from datatable , you know asp.net datatable object , not
    from database table!

    "Deasun" <> wrote in message
    news:D...
    > SELECT TOP 20
    > *
    > FROM TBL_TABLENAMEHERE
    >
    > Will do what you asked.
    >
    > Deasun
    >
    > "Ersin Gençtürk" wrote:
    >
    > > I can't find a expression for table views did i missed something ?
    > >
    > >
    > >
     
    Ersin Gençtürk, May 6, 2005
    #4
  5. Ersin Gençtürk

    BillGatesFan Guest

    dr() = datatable.select ("select Top 20 from tblorders")
     
    BillGatesFan, May 6, 2005
    #5
  6. It never works !!! DataTable.Select() works as a where clause...

    I assume SourceTable contains whole data and u don't need to sort it.

    DataTable outputTable = SourceTable.Clone();
    for(int i=0;i<20;i++)
    outputTable.ImportRow(SourceTable.Rows);

    outputTable contains top 20 records.

    --

    Thanks,
    Yunus Emre ALPÖZEN
    BSc, MCAD.NET

    "BillGatesFan" <> wrote in message
    news:...
    > dr() = datatable.select ("select Top 20 from tblorders")
    >
     
    Yunus Emre ALPÖZEN [MCAD.NET], May 6, 2005
    #6
  7. thanks yunus ,

    already this is the way that I am doing it.I think there is no other way to
    do it with dataview.

    "Yunus Emre ALPÖZEN [MCAD.NET]" <> wrote in message
    news:...
    > It never works !!! DataTable.Select() works as a where clause...
    >
    > I assume SourceTable contains whole data and u don't need to sort it.
    >
    > DataTable outputTable = SourceTable.Clone();
    > for(int i=0;i<20;i++)
    > outputTable.ImportRow(SourceTable.Rows);
    >
    > outputTable contains top 20 records.
    >
    > --
    >
    > Thanks,
    > Yunus Emre ALPÖZEN
    > BSc, MCAD.NET
    >
    > "BillGatesFan" <> wrote in message
    > news:...
    > > dr() = datatable.select ("select Top 20 from tblorders")
    > >

    >
    >
     
    Ersin Gençtürk, May 9, 2005
    #7
  8. Ersin Gençtürk

    P-Dub

    Joined:
    Jun 28, 2011
    Messages:
    1
    use Linq

    using System.Linq;
    ...
    dataTable.Take(20);
     
    P-Dub, Jun 28, 2011
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J. Babe
    Replies:
    1
    Views:
    8,432
    Kevin Spencer
    Aug 15, 2003
  2. =?Utf-8?B?S2VubmV0aA==?=

    Easiest way to bind a grid datasource to a datatable

    =?Utf-8?B?S2VubmV0aA==?=, Jan 18, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    6,804
    =?Utf-8?B?S2VubmV0aA==?=
    Jan 18, 2004
  3. Fredrik Rodin

    Sort a datatable and create a new datatable

    Fredrik Rodin, Feb 16, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    9,116
    paul.mariotti
    Sep 28, 2007
  4. =?Utf-8?B?Qmx1ZWZsb3dlcg==?=

    Casting DataTable to class inherit from DataTable

    =?Utf-8?B?Qmx1ZWZsb3dlcg==?=, Apr 2, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,038
    =?Utf-8?B?Qmx1ZWZsb3dlcg==?=
    Apr 2, 2004
  5. jg
    Replies:
    1
    Views:
    758
    =?Utf-8?B?U2hhaWxlc2ggSmFubnU=?=
    Aug 17, 2004
Loading...

Share This Page