1.

Syntax to create datatable in c#

Answer»

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;
}
}



Discussion

No Comment Found