DataTable.Rows : DataTable « System.Data « C# / C Sharp by API






DataTable.Rows

  

using System;
using System.IO;
using System.Data;

public class MainClass {
    static void Main(string[] args) {
        if (args.Length != 1)
            return;

        FileStream fs = new FileStream(args[0], FileMode.Open);
        DataSet ds = new DataSet();
        ds.ReadXml(fs);

        // Use a DataTable to display the members.
        DataTable mt = ds.Tables["member"];
        for (int row = 0; row < mt.Rows.Count; row++) {
            for (int col = 0; col < mt.Columns.Count - 1; col++) {
                Console.WriteLine("{0,-10}{1}",
                    mt.Columns[col].Caption,
                    mt.Rows[row][col].ToString().Trim());
            }
            Console.WriteLine();
        }
        fs.Close();
    }
}

   
    
  








Related examples in the same category

1.DataTable.Columns
2.DataTable.Columns.Add
3.DataTable.MinimumCapacity
4.DataTable.NewRow()
5.DataTable.Rows.Add