Solved

Question about working with single row in datatable?

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

12 Experts available now in Live!

Get 1:1 Help Now