Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > what is the easiest way to select top 20 rows from a datatable ?

Reply
Thread Tools

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

 
 
Ersin Gençtürk
Guest
Posts: n/a
 
      05-06-2005
I can't find a expression for table views did i missed something ?


 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGVhc3Vu?=
Guest
Posts: n/a
 
      05-06-2005
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 ?
>
>
>

 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      05-06-2005
"Deasun" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...

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


Assuming the RDBMS supports the "TOP" reserved word...


 
Reply With Quote
 
Ersin Gençtürk
Guest
Posts: n/a
 
      05-06-2005
I mean selecting from datatable , you know asp.net datatable object , not
from database table!

"Deasun" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> 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 ?
> >
> >
> >



 
Reply With Quote
 
BillGatesFan
Guest
Posts: n/a
 
      05-06-2005
dr() = datatable.select ("select Top 20 from tblorders")

 
Reply With Quote
 
Yunus Emre ALPÖZEN [MCAD.NET]
Guest
Posts: n/a
 
      05-06-2005
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[i]);

outputTable contains top 20 records.

--

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

"BillGatesFan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> dr() = datatable.select ("select Top 20 from tblorders")
>



 
Reply With Quote
 
Ersin Gençtürk
Guest
Posts: n/a
 
      05-09-2005
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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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[i]);
>
> outputTable contains top 20 records.
>
> --
>
> Thanks,
> Yunus Emre ALPÖZEN
> BSc, MCAD.NET
>
> "BillGatesFan" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
> > dr() = datatable.select ("select Top 20 from tblorders")
> >

>
>



 
Reply With Quote
 
P-Dub P-Dub is offline
Junior Member
Join Date: Jun 2011
Posts: 1
 
      06-28-2011
using System.Linq;
...
dataTable.Take(20);
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort a datatable and create a new datatable Fredrik Rodin ASP .Net 3 09-28-2007 07:28 AM
Create a Datatable from a SQL datatable column shema? jg ASP .Net 1 08-17-2004 09:43 PM
Casting DataTable to class inherit from DataTable =?Utf-8?B?Qmx1ZWZsb3dlcg==?= ASP .Net 0 04-02-2004 05:41 AM
Easiest way to bind a grid datasource to a datatable =?Utf-8?B?S2VubmV0aA==?= ASP .Net 2 01-18-2004 12:16 PM
Adding DataTable Rows To another DataTable J. Babe ASP .Net 1 08-15-2003 05:04 PM



Advertisments