468,534 Members | 2,265 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,534 developers. It's quick & easy.

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

I can't find a expression for table views did i missed something ?
Nov 19 '05 #1
6 5623
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 ?

Nov 19 '05 #2
"Deasun" <De****@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
SELECT TOP 20
*
FROM TBL_TABLENAMEHERE

Will do what you asked.


Assuming the RDBMS supports the "TOP" reserved word...
Nov 19 '05 #3
I mean selecting from datatable , you know asp.net datatable object , not
from database table!

"Deasun" <De****@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
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 ?

Nov 19 '05 #4
dr() = datatable.select ("select Top 20 from tblorders")

Nov 19 '05 #5
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" <kl******@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
dr() = datatable.select ("select Top 20 from tblorders")

Nov 19 '05 #6
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]" <ye***@msakademik.net> wrote in message
news:ec**************@TK2MSFTNGP15.phx.gbl...
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" <kl******@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
dr() = datatable.select ("select Top 20 from tblorders")


Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Luc | last post: by
3 posts views Thread by emailtonitin | last post: by
4 posts views Thread by Aaron Smith | last post: by
7 posts views Thread by wk6pack | last post: by
6 posts views Thread by ronchese | last post: by
16 posts views Thread by SLIMSHIM | last post: by
3 posts views Thread by Nuno Magalhaes | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.