OleDb: Return Row number value exists at

I am connecting a vb.Net app with an Access backend db. Each db record has a unique autonumber that is associated with it. How can I return the Row number that a specific autonumber exists at? Here is the code that I use to populate the dataset.

            con.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=c:\test.mdb;Jet OLEDB:Database Password=pass123;"
            sql = "SELECT * FROM [Table Name]"
            ds = New DataSet
            da = New OleDb.OleDbDataAdapter(sql, con)
            da.Fill(ds, "DBTABLE")
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.

Brian CroweDatabase AdministratorCommented:
first i need to ask why you need to rownumber.  although the rowindex within a datatable is static unless preceding rows are inserted or removed; within a dataview the rownumber doesn't mean much since imposing a sort order or rowfilter on the data changes the rowindex.

fyi, you don't need to open and close the connection with a dataadapter...it handles that internally.
rbichonAuthor Commented:
That is a small piece of the code. I am building a vb.Net form that will eventually replace our existing Microsoft Access front-end form. So I need the DataAdapter.

When a row is added or deleted by another user on another machine and the dataset is refreshed on this machine, the row numbers change. In order to keep track of what record I am on, I need to find the row number that coincides with the AutoNumber of my current record.

If you know of a better solution, please let me know.
Bob LearnedCommented:
Dim table As New DataTable
Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM [Table Name]", "Provider=Microsoft.JET.OLEDB.4.0;Data Source=c:\test.mdb;Jet OLEDB:Database Password=pass123;")

table.PrimaryKey = New DataColumn() {table.Columns("PrimaryKey")}

Dim findRow As DataRow = table.Rows.Find("primary key value goes here")


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
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.