How to add columns in DataTable?

 Posted by vishalneeraj-24503 on 12/20/2013 | Category: ADO.NET Interview questions | Views: 2299 | Points: 40
Answer:

DataTable has Columns property and Columns has Add static method,so with the help of Add method we can add any columns into DataTable.

For Example:-

DataTable dt_employee = new DataTable();

dt_employee.Columns.Add("Employee_Code");
dt_employee.Columns.Add("Employee_Name");


Here,Employee_Code and Employee_Name will be treated as DataTable Columns.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response