Row index

G

Guest

dir sir

I made a database contains a table named CONTACTS has the following attributes (Cont_id, Cont_Name, Address, Email, ...
In my application I have the value of the Cont_id, and I want to get the Index of the row(in the dataSet) that contains that Cont_i
(I`ve used OleDBDataAdapter and dataSet to connect to the database
How can I do that??!

thank
Mohamme
 
N

Nicholas Paldino [.NET/C# MVP]

Mohammed,

Unfortunately, there is not. You would have to cycle through the rows,
performing a comparison, and then noting the index of the row where you
found the values that matched.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Mohammed Abdel-Razzak said:
dir sirs

I made a database contains a table named CONTACTS has the following
attributes (Cont_id, Cont_Name, Address, Email, ...)
In my application I have the value of the Cont_id, and I want to get the
Index of the row(in the dataSet) that contains that Cont_id
 
B

Bill P.

Try this:

int contactId = 0;
DataRow dr = dataSet.Tables["Contacts"].Select(string.Format("Cont_di =
{0}", contactId))[0];

That should get you the DataRow that you are looking for, as for the index
of the actual row itself, there isn't a way to do it.

HTH,
Bill P.

Nicholas Paldino said:
Mohammed,

Unfortunately, there is not. You would have to cycle through the rows,
performing a comparison, and then noting the index of the row where you
found the values that matched.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Mohammed Abdel-Razzak said:
dir sirs

I made a database contains a table named CONTACTS has the following
attributes (Cont_id, Cont_Name, Address, Email, ...)
In my application I have the value of the Cont_id, and I want to get the
Index of the row(in the dataSet) that contains that Cont_id
(I`ve used OleDBDataAdapter and dataSet to connect to the database)
How can I do that??!!

thanks
Mohammed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top