By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,923 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

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

P: n/a
I can't find a expression for table views did i missed something ?
Nov 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
dr() = datatable.select ("select Top 20 from tblorders")

Nov 19 '05 #5

P: n/a
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

P: n/a
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.