471,582 Members | 1,412 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

getting the row number that contains unique data

Hi,
I have a DataTable and I'm trying to locate some data in a specific column
(my primary key column). The data I'm looking for is an int called xFile. I
may have the correct way to find the xFile (I'm not sure), but if so, what
I'm ultimately trying to do is find the number of the row that xFile is in.

Here's what I'm hoping finds xFile:

DataRow foundRow = tCat.Rows.Find(xFile);

No matter how long I search online, I can't find how to simply retrieve the
row number containing this unique xFile.

Thanks for any help!!!!!!!!!
Mel
Nov 17 '05 #1
1 1490
Hi there... There are three possible solutions for this (at least)...
1-. Iterate through the datatable, store in each loop the number of row
you're in (bad.. bad idea!!! and real slow... dismiss it)
2-. Add another column and make it autoincremental (let's call it...
RowID) so the table itself will maintain the number of row being inserted.
You already know what's the column (value) you're looking for... xFile
(BTW... where's Fox Mulder?!). Once you've found the row you're interested
in you can easily access the RowID column (this one works better and faster
than the previous)
3-. Why don't make xFile an autoincremental column?

Regards,
--
Angel J. Hernández M.
MCP - MCAD - MCSD - MCDBA
http://groups.msn.com/desarrolladoresmiranda
http://www.consein.com
"melanieab" <me*******@discussions.microsoft.com> escribió en el mensaje
news:5C**********************************@microsof t.com...
Hi,
I have a DataTable and I'm trying to locate some data in a specific column
(my primary key column). The data I'm looking for is an int called xFile.
I
may have the correct way to find the xFile (I'm not sure), but if so, what
I'm ultimately trying to do is find the number of the row that xFile is
in.

Here's what I'm hoping finds xFile:

DataRow foundRow = tCat.Rows.Find(xFile);

No matter how long I search online, I can't find how to simply retrieve
the
row number containing this unique xFile.

Thanks for any help!!!!!!!!!
Mel

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by sgottenyc | last post: by
2 posts views Thread by srusskinyon | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by Vinnie | last post: by
1 post views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

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.