473,811 Members | 2,963 Online
Bytes | Software Development & Data Engineering Community
+ 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 5967
SELECT TOP 20
*
FROM TBL_TABLENAMEHE RE

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****@discuss ions.microsoft. com> wrote in message
news:D0******** *************** ***********@mic rosoft.com...
SELECT TOP 20
*
FROM TBL_TABLENAMEHE RE

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****@discuss ions.microsoft. com> wrote in message
news:D0******** *************** ***********@mic rosoft.com...
SELECT TOP 20
*
FROM TBL_TABLENAMEHE RE

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.selec t ("select Top 20 from tblorders")

Nov 19 '05 #5
It never works !!! DataTable.Selec t() works as a where clause...

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

DataTable outputTable = SourceTable.Clo ne();
for(int i=0;i<20;i++)
outputTable.Imp ortRow(SourceTa ble.Rows[i]);

outputTable contains top 20 records.

--

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

"BillGatesF an" <kl******@hotma il.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
dr() = datatable.selec t ("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***@msakadem ik.net> wrote in message
news:ec******** ******@TK2MSFTN GP15.phx.gbl...
It never works !!! DataTable.Selec t() works as a where clause...

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

DataTable outputTable = SourceTable.Clo ne();
for(int i=0;i<20;i++)
outputTable.Imp ortRow(SourceTa ble.Rows[i]);

outputTable contains top 20 records.

--

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

"BillGatesF an" <kl******@hotma il.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
dr() = datatable.selec t ("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
8128
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 DataTable(); dt.Columns.Add("Number", System.Type.GetType("System.Int32")); dt.Columns.Add("Value", System.Type.GetType("System.Double")); for(int i=0;i<2000;i++) {
2
2074
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 DataTable("Total") ' Add two columns
3
3697
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
2621
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, "Facilities").Position = iPos That is the code.. dr is DataRow. If dr.Item("ID") = 3, the find will return position 0, which it should have been 1, and if the ID = 2, it will return 1, which should have been 0.. The DA has a connection string that sorts it...
7
14999
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
4694
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 a field containing the following value (extracted from Immediate Window): ?dtbSample.Rows(0).Item("COM_STARTDATE") #5/8/2006 9:00:00 AM# {Date} Date: #5/8/2006 9:00:00 AM# (for better understand, consider this date as '2006/05/08')
1
5742
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 work manually. I am looking for an automated way. Thank you, Max
16
1876
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 the form controls. I"m trying to do it solely thru code. You can safely assume I have an access datsabase with one table called who with three columns(fields). where did i go wrong ? OleDbConnection con;
3
2829
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 use it on Select? Thank you, Nuno Magalhães.
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10401
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9217
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7676
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5567
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4357
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 we have to send another system
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.