473,668 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Filter rows in a DataSet

Hi all:
I have a DataSet populated with values. How can I return
ds.Tables[0].DefaultView's records from a starting number to a ending
number?
For example, I have 100 records in the DefaultView, but I just need
records from 25th to 50th.

Thanks for any suggestion!

--

WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
Nov 15 '05 #1
4 15170
hi,

use a for-loop and start at 25 and end at 50 e.g (not tested code)

for (int = 0; i<=50;i++)
{
DataSet.Tables[i].DefaultView;
}

--
Mit freundlichen Gruessen - Regards

Ralph Gerbig
ik********@web. de
www.ralphgerbig.de.vu

Because of some spam isues I'm not able
to response to all e-mail requests.
Nov 15 '05 #2
Thanks!
But not loop through DataTables.
What I need are records within a DataView from record 25 to record 50.
"Ralph Gerbig" <ik********@web .de.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
hi,

use a for-loop and start at 25 and end at 50 e.g (not tested code)

for (int = 0; i<=50;i++)
{
DataSet.Tables[i].DefaultView;
}

--
Mit freundlichen Gruessen - Regards

Ralph Gerbig
ik********@web. de
www.ralphgerbig.de.vu

Because of some spam isues I'm not able
to response to all e-mail requests.

Nov 15 '05 #3
If you are using the DefaultView and you don't have a filter condition, then
Ralph's implementation will work. Assuming that you only want to work with
a DataView, you can use the same logic, just change the reference from
DataSet.Table to DataView. In general, I prefer an enumerator like this,
but it's 6 of one half dozen of the other but you can use a for loop for a
better implementation for this specific issue...

for(int i = 25; i<=50; i++){
Debug.WriteLine (row[i];
}

If you have a column who's number corresponds to row value, then you can use
something like

DataRow[] dRows = ds.Tables[0].Select("ID > 25 and ID < 51) //Since you are
using Defaultview, this should work as well even if you don't use the view
per se.

--This is the enumerated example, just for reference b/c it's the better
solution here.
DataView v = new DataView(ds.Tab les[0].DefaultView);

DataRowView dro;

IEnumerator myEnum = v.GetEnumerator ();
int x = 0;
while(myEnum.Mo veNext()){
//Check for the row position
if(x >25 and x < 51){
Debug.WriteLine (
}
i++
}
"Hardy Wang" <ha********@mar ketrend.com> wrote in message
news:%2******** **********@TK2M SFTNGP10.phx.gb l...
Hi all:
I have a DataSet populated with values. How can I return
ds.Tables[0].DefaultView's records from a starting number to a ending
number?
For example, I have 100 records in the DefaultView, but I just need
records from 25th to 50th.

Thanks for any suggestion!

--

WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy

Nov 15 '05 #4
You can create a new DataColumn (say RowNum) and set its AutoIncrement
property to true and have its AutoIncrementSe ed and AutoIncrementSt ep as 1.
You can add this column to the Datatable b4 you do a Fill. To keep things
simple, select a column name that does not clash with the result set schema.
Finally, after a DataView is created from the DataTable, you can use a
FilterExpressio n likeRowNum >= 25 and RowNum <= 50.
I am not sure if a simpler approach is possible.

--
HTH,
Manoj G [.NET MVP]
http://www15.brinkster.com/manoj4dotnet

"Hardy Wang" <ha********@mar ketrend.com> wrote in message
news:#j******** ******@TK2MSFTN GP10.phx.gbl...
Hi all:
I have a DataSet populated with values. How can I return
ds.Tables[0].DefaultView's records from a starting number to a ending
number?
For example, I have 100 records in the DefaultView, but I just need
records from 25th to 50th.

Thanks for any suggestion!

--

WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2699
by: akash D | last post by:
I have two list boxes, I want to filter items of second list box based on selcted items of First list box *** Sent via Developersdex http://www.developersdex.com ***
1
8797
by: SPG | last post by:
Hi, I need to be able to filter the columns that are visible through a dataset. That is, I can have all columns in a dataset, but only some of them are visible when filtered. I know you can use rowfilter on a dataview. Is there anything like that I can use? Steve
3
5183
by: Dan V. | last post by:
How can I use real SQL on a DataTable? i.e. not array of rows using a filter... as in DataTable.Select. I read at : microsoft.public.dotnet.framework.adonet "As others have posted: There is no SQL query processor for DataSets. You can use XPath with an XMLDataDocument built from the DataSet. You can also perform selections based on criteria, using the Find and Select methods, and you can create row filters using DataViews."
1
1740
by: werk | last post by:
For limiting access to the database to strictly necessary I try to filter the query by using DataView. Thw DataSet ds contains three columns (fields) : (LAND_ID, Landcode, Landnaam) and four rows. I try to filter out only one country (key is LAND_ID) with the following code: DataTable dt = ds.Tables; // ds contains the dataset of the query 4 rows
8
1507
by: ruca | last post by:
Hi gurus, How can I filter data in my DataSet and then put the result in a DataGrid? NOTE: I'm reading a txt file into a dataset with 3 columns: Id, Name, Age I have this: code------------------------------------------------------------------------
2
1743
by: Danny Ni | last post by:
Hi, I would like to know the fastest way to clone a dataset with filter inVB.Net or C#. Say I have a dataset that has one datatable having several data rows. I want to clone the structure to another dataset but with selection of datarows. Please Help!
4
1623
by: Bo Diddly | last post by:
This is what I've done so far: I have a DataBase with: tblBook BookID... key Book... All the book titles of the Bible tblChapter ChapterID... key Chapter... chapter numbers (1 - 150)
6
1541
by: mike11d11 | last post by:
I cant seem to filter down my dataset table by criteria in expression. Can someone tell me why I still have the same amount of rows after I use this filter select option. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.WorkListTableAdapter.Fill(Me.SQLDataSet.WorkList)
2
5586
by: Raymond Chiu | last post by:
Dear all, If I have the dataset, What the code should be to filter records in the dataset by some fields criteria? Is it like a SQL? Thanks for your help,
0
8459
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
8889
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8790
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
8652
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6206
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
5677
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2782
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
2017
muto222
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.