Solved

Question about working with single row in datatable?

Posted on 2007-03-26
1
212 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Error - Add Failed 12 78
This code tracks birthdays 3 60
ASP.NET 5 Templates 2 66
C# Comparing String Arrays. 5 26
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now