How to use Data Table


Friday, August 21, 2009

Below code will teach you how to use DataTable in C#

To create datatable and add table to dataset

DataSet ds1=new DataSet();
DataTable table=ds1.Tables.Add("Table");

to add columns in table

table.Columns.add("dDatePlayed");
keep adding..........

to create new row in the datatable

DataRow row=table.NewRow();

to add item in the itemarray of the table and you can add later all together in table

row["dDatePlayed"]=ds.Tables[0].Rows[i]["dDatePlayed"].ToString();

Add complete row form itemarray of table to actual table

table.Rows.Add(row);


For More details contact,
Rajesh Singh
Asp.Net Developer
Indianic infotech ltd (India)
rajesh@indianic.com

No comments :