Solved

Question about working with single row in datatable?

Posted on 2007-03-26
1
215 Views
Last Modified: 2010-04-16
What is the appropriate way to read data from a single row in a datatable.

I have a dataset table adapter that returns a single row.

In a situation where I needed to work through multiple rows I would do a

foreach (DataRow r1 in areaDT)

Is that the correct way to pull data from a single row or is there a more efficeint way to do it when you know its only a si ngle row returned?
0
Comment
Question by:Prysson
1 Comment
 
LVL 7

Accepted Solution

by:
badbearontour earned 500 total points
ID: 18793439
Hi,

I would just use a similar setting to below, if you can guarantee that the dataAdapter will only ever return one row.


datarow myOneRow = datatableAdapterGetMyOneRow();  //assuming the method only returns a dataRow and not a dataRow[]!!

string example = myOneRow["NameForInstance"].toString();

I dont know of any other way you could deal with a dataRow

BB
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question