?
Solved

C# Datatable  - how to extract a specific value

Posted on 2014-03-27
3
Medium Priority
?
238 Views
Last Modified: 2014-03-27
Hi All

I have a C# datatable populated by a SQL statment.

Say the datatable has returned a 100 records and there are five coloumn headers, how do I just display record 50, coloumn 2 from the datatable

I'd guess something like Console.Write(MyDatatable.rows[50].Coloumns[2])

but it's just not happening
0
Comment
Question by:MrDavidThorn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 39959211
You can access a row's ItemArray
0
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 2000 total points
ID: 39959224
like
MyDatatable.Rows[50].ItemArray[2]
0
 
LVL 9

Expert Comment

by:dustock
ID: 39959237
Its going to be base 0 so you'll want this.

MyDataTable.Rows[49].ItemArray[1].ToString();

Open in new window

0

Featured Post

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

752 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