By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,837 Members | 1,222 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,837 IT Pros & Developers. It's quick & easy.

ADO.NET, need to get index of datarow

P: n/a
BB
Hello all,

I am using the currency manager in VB to navigate a
dataset. I know how to use .position to loop through the
rows, but what I want to do is *get* the position of the
row I just added/updated, so that I can reposition the
currency manager there sometime later.

Seems like after I add a detached datarow to the
datatable, that index should be sitting there somewhere
for me to grab, but I don't see where that is in either
the currency manager, the dataset itself, etc. I can
always redo the i/o to re-retrieve the datarow, but that
seems like a waste.

Any ideas?

TIA,

BB
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Suggest you repost this 'Q' to adonet newsgroup.

Regards - OHM
BB wrote:
Hello all,

I am using the currency manager in VB to navigate a
dataset. I know how to use .position to loop through the
rows, but what I want to do is *get* the position of the
row I just added/updated, so that I can reposition the
currency manager there sometime later.

Seems like after I add a detached datarow to the
datatable, that index should be sitting there somewhere
for me to grab, but I don't see where that is in either
the currency manager, the dataset itself, etc. I can
always redo the i/o to re-retrieve the datarow, but that
seems like a waste.

Any ideas?

TIA,

BB

Nov 20 '05 #2

P: n/a
Cor
Hi BB,

The currency manager gives you the current row on your control
(so I thought that you don't have to use a loop for updating)
The last added row in a dataset is as far as I know always
dataset.tables(x).rows.count - 1

And if you want to know a row you are updating using a loop, why not just
use a loop like
\\\
dim i as integer
for i = 1 to dataset.tables(x).rows.count - 1
do something with the found row
datset.tables(x).rows(i).item("myitem") etc
if found lastrow = i
exit for
next
///
I hope this was where you was after?

Cor

I am using the currency manager in VB to navigate a
dataset. I know how to use .position to loop through the
rows, but what I want to do is *get* the position of the
row I just added/updated, so that I can reposition the
currency manager there sometime later.

Seems like after I add a detached datarow to the
datatable, that index should be sitting there somewhere
for me to grab, but I don't see where that is in either
the currency manager, the dataset itself, etc. I can
always redo the i/o to re-retrieve the datarow, but that
seems like a waste.

Nov 20 '05 #3

P: n/a
Good advice for a newbie...thanks.
-----Original Message-----
Suggest you repost this 'Q' to adonet newsgroup.

Regards - OHM
BB wrote:
Hello all,

I am using the currency manager in VB to navigate a
dataset. I know how to use .position to loop through the rows, but what I want to do is *get* the position of the row I just added/updated, so that I can reposition the
currency manager there sometime later.

Seems like after I add a detached datarow to the
datatable, that index should be sitting there somewhere
for me to grab, but I don't see where that is in either
the currency manager, the dataset itself, etc. I can
always redo the i/o to re-retrieve the datarow, but that seems like a waste.

Any ideas?

TIA,

BB

.

Nov 20 '05 #4

P: n/a
* "BB" <an*******@discussions.microsoft.com> scripsit:
I am using the currency manager in VB to navigate a
dataset. I know how to use .position to loop through the
rows, but what I want to do is *get* the position of the
row I just added/updated, so that I can reposition the
currency manager there sometime later.

Seems like after I add a detached datarow to the
datatable, that index should be sitting there somewhere
for me to grab, but I don't see where that is in either
the currency manager, the dataset itself, etc. I can
always redo the i/o to re-retrieve the datarow, but that
seems like a waste.


..NET + Database group:

<news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet>

Web interface:

<http://msdn.microsoft.com/newsgroups/default.asp?url=/newsgroups/loadframes.asp?icp=msdn&slcid=us&newsgroup=microso ft.public.dotnet.framework.adonet>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

P: n/a
Hi BB,

Not too many people know how to get a row index using ado .net and many will
tell you any number of reasons why you don't need it - but you and I know
that you do.

I wrote a function that will do this for you by returning the index of the
row in question. Note that in the code below 'functions' is a class in a
..dll called 'imcfunctionlib'.
Public Function findindex(ByVal dt As DataTable, ByVal dr As DataRow) As
Integer

' signature:

' dim funcs as new imcfunctionlib.functions

' dim xint as integer

' xint = funcs.findindex(dsmanifest.tables(0),irow)

' when you call findindex inside a loop the current irow index is returned
with

' idex = findindex(ods.Tables(0), irow)

' at the same time, this

' MessageBox.Show(irow("imcacct"))

' equals

' MessageBox.Show(ods.Tables(0).Rows(idex)("imcacct" ))

' once outside the loop - see dataworks for more info

Dim i As Integer

For i = 0 To dt.Rows.Count - 1

If Object.ReferenceEquals(dt.Rows(i), dr) Then

Return i

End If

Next

Return -1

End Function

HTH,

Bernie Yaeger

"BB" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...
Hello all,

I am using the currency manager in VB to navigate a
dataset. I know how to use .position to loop through the
rows, but what I want to do is *get* the position of the
row I just added/updated, so that I can reposition the
currency manager there sometime later.

Seems like after I add a detached datarow to the
datatable, that index should be sitting there somewhere
for me to grab, but I don't see where that is in either
the currency manager, the dataset itself, etc. I can
always redo the i/o to re-retrieve the datarow, but that
seems like a waste.

Any ideas?

TIA,

BB

Nov 20 '05 #6

P: n/a
Bernie, this was a big help. Thanks.
-----Original Message-----
Hi BB,

Not too many people know how to get a row index using ado .net and many willtell you any number of reasons why you don't need it - but you and I knowthat you do.

I wrote a function that will do this for you by returning the index of therow in question. Note that in the code below 'functions' is a class in a..dll called 'imcfunctionlib'.
Public Function findindex(ByVal dt As DataTable, ByVal dr As DataRow) AsInteger

' signature:

' dim funcs as new imcfunctionlib.functions

' dim xint as integer

' xint = funcs.findindex(dsmanifest.tables(0),irow)

' when you call findindex inside a loop the current irow index is returnedwith

' idex = findindex(ods.Tables(0), irow)

' at the same time, this

' MessageBox.Show(irow("imcacct"))

' equals

' MessageBox.Show(ods.Tables(0).Rows(idex)("imcacct" ))

' once outside the loop - see dataworks for more info

Dim i As Integer

For i = 0 To dt.Rows.Count - 1

If Object.ReferenceEquals(dt.Rows(i), dr) Then

Return i

End If

Next

Return -1

End Function

HTH,

Bernie Yaeger

"BB" <an*******@discussions.microsoft.com> wrote in messagenews:09****************************@phx.gbl...
Hello all,

I am using the currency manager in VB to navigate a
dataset. I know how to use .position to loop through the rows, but what I want to do is *get* the position of the row I just added/updated, so that I can reposition the
currency manager there sometime later.

Seems like after I add a detached datarow to the
datatable, that index should be sitting there somewhere
for me to grab, but I don't see where that is in either
the currency manager, the dataset itself, etc. I can
always redo the i/o to re-retrieve the datarow, but that seems like a waste.

Any ideas?

TIA,

BB

.

Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.