473,325 Members | 2,480 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,325 software developers and data experts.

Working with Datatable.


Hello,
I have a Datatable "dt" with say "n" rows.
I want to return a subset of "dt" starting at index "i" (i<dt.Rows.Count)
and ending at index "j" ( dt.Rows.Count >j>i).
How can this be done without unnecessary coding?
Many thanks in advance.

JB

Nov 17 '05 #1
4 1198
Hi,

Use the DataView.RowFilter or DataTable.Select(...)
More info in .NET docs.

Marcin
Hello,
I have a Datatable "dt" with say "n" rows.
I want to return a subset of "dt" starting at index "i" (i<dt.Rows.Count)
and ending at index "j" ( dt.Rows.Count >j>i).
How can this be done without unnecessary coding?
Many thanks in advance.

JB


Nov 17 '05 #2
> Use the DataView.RowFilter or DataTable.Select(...)
More info in .NET docs.

Right but i will have to write some fairly complex sql script. I thought
there was
some more straight forward way out.
Thank you anyway.
JB
Nov 17 '05 #3
Hi again,
Use the DataView.RowFilter or DataTable.Select(...)
More info in .NET docs.


Right but i will have to write some fairly complex sql script. I thought
there was
some more straight forward way out.
Thank you anyway.


I understand that you want to return some DataRow(s) that
have indices between i and j (e.g. 11 - 20). I'm right?

If i'm right:
DataRow[] selectedRows=new DataRow[(j-i)+1];
for(int index=0; index<selectedRows.Length; index++) {
selectedRows[index]=dataTable.Rows[i+index];
}

HTH
Marcin
Nov 17 '05 #4
> If i'm right:
DataRow[] selectedRows=new DataRow[(j-i)+1];
for(int index=0; index<selectedRows.Length; index++) {
selectedRows[index]=dataTable.Rows[i+index];
}

HTH
Marcin


very impressive!

Thanks.

JB
Nov 17 '05 #5

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

Similar topics

9
by: Bob Achgill | last post by:
I would like some example code that shows retrieving and updating selected column data from a DataTable. I am sucessful to load and select the whole row of a DataTable into a datagrid. But...
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
5
by: George | last post by:
I have set DataAdapter.AcceptChangesDuringUpdate = true; However, I find that I still need to call AcceptChanges on the associated DataTable, DataTable.AcceptChanges(); Has anyone...
1
by: matt | last post by:
hello, i have a web app that allows users to query our oracle db and produce a dataset of report data. they then have the option to serialize this data and store it in the database. later, then...
3
by: UJ | last post by:
I've got a working web service that we are moving to another machine and now I suddenly get the following error. While transferring the files, got the following message:...
4
by: Tomasz Jastrzebski | last post by:
Hello Everyone, I have a GridView control bound to a plain DataTable object. AutoGenerateEditButton is set to true, Edit button gets displayed, and RowEditing event fires as expected.
4
by: =?Utf-8?B?cmFuZHkxMjAw?= | last post by:
I'm working in Visual Studio 2005 and C#. I have a DataTable with many rows. The user can delete a row. After the row is deleted, I'd like to column values for the deleted row, but any attempt to...
0
jas16183
by: jas16183 | last post by:
Hi Guys, need some help here, Im working on a project in vb.net, the problem im facing is that my tableadapter.update(dataset.datatable) is not functioning, the datatable has a relation with...
11
by: lenygold via DBMonster.com | last post by:
Hi everybody! This query is supposed to count consecutive years from the current year without OLAP. Input Table: ID DateCol 1 02/01/2006 1 01/01/2006 1 01/01/2005
1
by: Sukh | last post by:
Hi All, Can anyone help me to understand this. please see the code: private fun1(){ int count1, count2; string strTest; DataTable dt = new DataTable();
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.