Hi Guest

MobileUser

1 HomePage 1 Jobs 1 WalkIn 1Articles  

Cat Exam

 :) Latest Topic
AJAX
VB.NET
SQL Query
UDDI
CLASS
JavaScript Questions
SharePoint Interview
SilverLight
WCF
general knowledge
 ASP.NET
 :) Hot Jobs
 
 :) Latest Articles


  

 


Syntax to create datatable in c#
Question Posted on 03 Sep 2011

Home >> DotNet >> C# >> Syntax to create datatable in c#




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



 
 Input Your Comments Or suggestions(If Any)
 Name
 Email(optional)
 Comments


Other Important Questions
Simplest definition of partial classes and its rules?
Definition of Tuple class with some examples?
Define Race Condition in cSharp?
C#.Net Reserve Words
can we inherit private class level variables in c#






 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |