• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

C# Datatable - how to extract a specific value

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
MrDavidThorn
Asked:
MrDavidThorn
  • 2
1 Solution
 
Jens FiedererTest Developer/ValidatorCommented:
You can access a row's ItemArray
0
 
Jens FiedererTest Developer/ValidatorCommented:
like
MyDatatable.Rows[50].ItemArray[2]
0
 
dustockCommented:
Its going to be base 0 so you'll want this.

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

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now