Navigating a dataset 'randomly'

Navigating a dataset 'randomly'

Post by mklap » Fri, 05 Dec 2003 03:40:39


Hello,

I retrieve all the Ids from a DB table. The 'current'
Id is used to retrieve all the columns associated with
that Id. I need to Move Next and Move Previous.
The DBEnumerator is a Forward-only tool.
A "For Each Row" solution would enclose nearly the
entire application in the loop and still would not work.
Since a "Find" is supported, maintaining a Global
index to step through the rows collection would not be
effective.
There are upwards of 14,000 rows in the table, so I am
not eager to use an array.
I must use a Web Service and ADO.NET disconnected
datasets.

How does one navigate forward and backward relative to
the current row without knowing the index (or can we
learn the index? The DBEnumerator was promising, but it
is forward only.

mklapp
 
 
 

Navigating a dataset 'randomly'

Post by Miha Marki » Fri, 05 Dec 2003 04:36:09

Hi mklapp,

You'll have to use foreach to find a index of the current row.
Once you have the index, you can freely select index+-n row.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

 
 
 

Navigating a dataset 'randomly'

Post by mklap » Fri, 05 Dec 2003 05:11:43

I was afraid it would come down to that. Frankly, I am
surprised the removal of such a basic functionality would
even be tolerated.

Thanks for ending the search

mklapp

current row.
row.


The 'current'
work.
am
to
it
 
 
 

Navigating a dataset 'randomly'

Post by v-kev » Fri, 05 Dec 2003 12:26:28

Hi mklapp,

I think miha is right, you can maintain the current index after the first
time you find it in the DataTable.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
 
 

Navigating a dataset 'randomly'

Post by Miha Marki » Fri, 05 Dec 2003 17:41:27

?
I've never missed it...

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
 
 
 

Navigating a dataset 'randomly'

Post by Frank Oque » Fri, 05 Dec 2003 22:29:26


What's wrong with DataTable.Select()?

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://www.yqcomputer.com/
(Pull the pin to reply)
 
 
 

Navigating a dataset 'randomly'

Post by mklap » Thu, 11 Dec 2003 03:47:27

My particular problem lies in the fact this is an old app
(VB3 originally). The users expect identical
functionality and since interaction with the users is not
scheduled by the client....

The users like to MoveNext and MovePrevious.

To accomodate this, every time a find or select is
executed, I run a binary search on the table to locate
the retrieved row's position in the Rows collection. That
way I am looking at about 10 rows or less to retrieve the
index (not the key).

I have not yet genericized the routine to the point I
pass a table reference, a column index and a comparison
string but I suppose I will and I will keep it in
my 'toolkit'.

mklapp

index after the first
and confers no
 
 
 

Navigating a dataset 'randomly'

Post by v-kev » Thu, 11 Dec 2003 14:32:55

Hi mklapp,

I think this is the only way to search for the index of the row in a
DataTable. Thanks for your feedback and sharing your experience with us in
the newsgroup.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."