How to create a column in the DataTable?

 Posted by Raja on 6/7/2009 | Category: ADO.NET Interview questions | Views: 4156
Answer:

To create a column in the DataTable we can use the Columns.Add method of the DataTable object and pass DataColumn object as parameter.

DataTable dTable = new DataTable();

// create another column
DataColumn name = new DataColumn("Name", typeof(string));
dTable.Columns.Add(name);


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response