473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 15153
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****************@TK2MSFTNGP09.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.Tables[0].DefaultView);

DataRowView dro;

IEnumerator myEnum = v.GetEnumerator();
int x = 0;
while(myEnum.MoveNext()){
//Check for the row position
if(x >25 and x < 51){
Debug.WriteLine(
}
i++
}
"Hardy Wang" <ha********@marketrend.com> wrote in message
news:%2******************@TK2MSFTNGP10.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 #4
You can create a new DataColumn (say RowNum) and set its AutoIncrement
property to true and have its AutoIncrementSeed and AutoIncrementStep 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
FilterExpression 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********@marketrend.com> wrote in message
news:#j**************@TK2MSFTNGP10.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
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
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...
3
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...
1
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...
8
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: ...
2
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...
4
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
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...
2
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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,...

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.