473,386 Members | 1,835 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.

using DataViews to jump to a sorted set of records without scanning the whole view

I've created a DataView in C#.

I've also sorted my records on product_name.

If I return 6000 products and want to get to products
(3000-3020) I wrote the following code:

WriteView(myView,3000,3020)

public void WriteView(DataView myView,int startIdx,int endIdx)
{
int n;
n=0;
myView.Sort="product_name";

foreach (DataRowView myDRV in myView)

{
n=n+1;
for (int i = 0; i < myView.Table.Columns.Count; i++)
{
if ((n > startIdx) && (n < endIdx))
{
Console.Write(myDRV[i] + "\t");
Console.WriteLine("");
}
}
}

When I run this it works but I wonder if I can get the same result
without having to scan through the DataView.

I've tried skipping over the first 3000 records using the command
Console.WriteLine(myView.Table.Rows[j][i]);

where j=3000 to 3020 but this does not return the sorted order; it
returns the DataView in the intial sequence that it was first fetched
from the dbase.

Does anyone have any other suggestions.

Thanks

J.C. Klay
Nov 15 '05 #1
1 1153
J. C. Clay,

If the index is stored in the data set itself in a column, then you can
set the RowFilter property to the following and it should work:

// Set the filter to only include items in the index range.
myView.RowFilter = String.Format("<fieldname> > {0} and <fieldname> < {1}",
startIdx, endIdx);

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"J. C. Clay" <bi********@yahoo.com> wrote in message
news:30**************************@posting.google.c om...
I've created a DataView in C#.

I've also sorted my records on product_name.

If I return 6000 products and want to get to products
(3000-3020) I wrote the following code:

WriteView(myView,3000,3020)

public void WriteView(DataView myView,int startIdx,int endIdx)
{
int n;
n=0;
myView.Sort="product_name";

foreach (DataRowView myDRV in myView)

{
n=n+1;
for (int i = 0; i < myView.Table.Columns.Count; i++)
{
if ((n > startIdx) && (n < endIdx))
{
Console.Write(myDRV[i] + "\t");
Console.WriteLine("");
}
}
}

When I run this it works but I wonder if I can get the same result
without having to scan through the DataView.

I've tried skipping over the first 3000 records using the command
Console.WriteLine(myView.Table.Rows[j][i]);

where j=3000 to 3020 but this does not return the sorted order; it
returns the DataView in the intial sequence that it was first fetched
from the dbase.

Does anyone have any other suggestions.

Thanks

J.C. Klay

Nov 15 '05 #2

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

Similar topics

8
by: tom | last post by:
I am new to SQL administration. >From a list of IDs that are the primary key in one table (i.e. Customer Table), I want to make changes in tables that use those IDs as a foreign key. ...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
22
by: Bradley | last post by:
Has anyone else noticed this problem? I converted the back-end to A2000 and the performance problem was fixed. We supply a 97 and 2000 version of our software so we kept the backend in A97 to make...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
5
by: Chand | last post by:
Private Sub tbDate_AfterUpdate() Dim cnn As New ADODB.Connection Dim rst As New ADODB.Recordset rst.CursorLocation = adUseClient Set cnn = CurrentProject.Connection rst.Open "SELECT * FROM...
9
by: DraguVaso | last post by:
Hi, I have two DataTables (our DataViews or whatever that will suit the best for the solution). I want to merge these two DataTables the fastest as possible, but they have to be merged one table...
3
by: sean | last post by:
I have a table with fixed row of records SORTED by DATE using ADO pagination method. The user can click a link in one table cell and go to another page to modify the record. Once the updated record...
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.