How to find the row number of a datarow from a datatable ?

How to find the row number of a datarow from a datatable ?

For example:

Private sub test(byref inRow as datarow)
...
...
' how can I detect the row number of inRow here where inRow is a datarow from a datatable ?
end sub

vbhahaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DabasCommented:
Hi vbhaha:
    A datarow does not "know" its position within the table.
    You would have to search your table for the row, but I have the feeling that is not your intention.

Dabas
0
vbhahaAuthor Commented:
Hi Dabas,

If it don't know its position, then the only thing I can do is to search the whole datatable before further process !!!

vbhaha
0
DabasCommented:
vbhaha:
That is right.

Question is, what exactly you want to do, and if there is not a more efficient way of doing it.
Why do you need to know the position within the table?

Dabas
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

vbhahaAuthor Commented:
Actually, my application has two layers, UI layer and data update layer.

The UI layer handles all user actions, change, add, delete, move next, move previous (only one record will be changed each time),

After the user press "Update" button, it will pass the datatable into update layer for updating, if I know the row position then I don't need to search the whole datatable.

0
DabasCommented:
vbhaha:
If your table is indexed, then you should be able to use an INSERT, UPDATE or DELETE SQL statement to do your updating.
No need to know the position of your row in the table.

Dabas
0
arif_eqbalCommented:
What do you want to do When you get the Row Number of that particular DataRow within the dataTable ???

Whetever information you can get from the dataTable is probably already there in the dataRow.

Also How is this dataRow created, is it in Sync with the DataTable ??

0
DabasCommented:
vbhaha:
By the way vbhaha, you seem to have an awful grading reputation!
Any reason why you give out so many B and C grades?

Dabas
0
arif_eqbalCommented:
What I meant with dataRow being in Sync was if the dataRow has been instantiated from the same dataTable then we can search using a key field

eg.

Dim DV As DataView = New DataView(YourDataTable, "", "Key_Field_Name", DataViewRowState.CurrentRows)
Dim RowNo as Integer
RowNo  = DV.Find(YourDataRow("Key_Field_Name")

This will give you the Row No of the DataRow within the DataTable

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vbhahaAuthor Commented:
vbhaha:
If your table is indexed, then you should be able to use an INSERT, UPDATE or DELETE SQL statement to do your updating.
No need to know the position of your row in the table.

Dabas
--------------------------------------------------------------------------------
For simple updating you're right, however if the program need to update other tables then ....!

For example:

After update the invoice details (with product no, qty), then it also needs to update the product table for +/- the quantity, OR for writing insertion log/deletion log ...etc

That why I need to know which row has been updated...!

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.