Below class is used to create a table and how to use that table
using System;
using System.Data;
class CreateTableProgram
{
static void Main()
{
//
//Create a table object and Get the DataTable.
//
DataTable table = GetTable();
}
/// Below is syntax to generates a DataTable.
static DataTable GetTable()
{
//
// Here we create a DataTable with four columns.
//
DataTable table = new DataTable();
table.Columns.Add("EmployeeId", typeof(int));
table.Columns.Add("Name", typeof(string));
table.Columns.Add("Address", typeof(string));
//
// Here we add some DataRows.
//
table.Rows.Add(1, "Suresh", "Delhi");
table.Rows.Add(2, "Mahesh", "Mumbai");
table.Rows.Add(3, "Gitesh", "Haryana");
table.Rows.Add(4, "Vitesh", "Goa");
return table;
}
} | |