473,471 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 5933
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Luc | last post by:
I am using Visual Studio 2003 and am getting lousy performance after using a datatable select and then trying to assign a value to a column of the row that was found: DataTable dt = new...
2
by: Kenneth | last post by:
Hi, I want to make sure I got the easiest way on how to bind a grid's datasource to a datatable. I've made an in-memory datatable Dim dtTotal As DataTable Dim drow As DataRow dtTotal = New...
3
by: emailtonitin | last post by:
Hi, I am having a problem with the default sorting mechanism employed by the datatable.select method - I have a datatable having rows (simplified for clarity) - name ----- c a
4
by: Aaron Smith | last post by:
Dim dv As DataView = New DataView(FacilitiesDS1.Facilities, "", "ID ASC", DataViewRowState.CurrentRows) Dim iPos As Integer = dv.Find(dr.Item("ID")) Me.BindingContext(FacilitiesDS1,...
7
by: wk6pack | last post by:
Hi, How do I check datatable.select(filter) in the following: for each dtrow in datatable.select(filter) .... next I've also tried:
6
by: ronchese | last post by:
Hi. I'm trying to make a criteria string to use in Select() method of a datatable, searching for a date, but it is apparently not working! In one of my tests, I have a datatable with 1 row and...
1
by: Maxwell2006 | last post by:
Hi, I am working with strongly typed datatables. What is the most efficient way to build a new DataTAble based on the result of DataTable.Select? At this point I use a foreach loop to do the...
16
by: SLIMSHIM | last post by:
Hi, I"m new to c# and .net. I wrote a small program to add rows to an access table. the program goes thru the motions but the data never gets there. here is my code. I am intentionaly not using...
3
by: Nuno Magalhaes | last post by:
Hello, I have a DataTable in which the items are of type MyClass. How can I use Select to compare a MyClass instance with the DataTable? Is there any overriden method (like the ToString()) to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.