Solved

C# Datatable  - how to extract a specific value

Posted on 2014-03-27
3
236 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 500 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

734 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