//創建DataTable
DataTable dt = new DataTable();
dt.Columns.Add("id",Type.GetType("System.Int32"));
dt.Columns["id"].AutoIncrement = true;
dt.Columns.Add("name",Type.GetType("System.String"));
//插入數據
DataRow dw1 = dt.NewRow();
dw1["name"] = "test1";
dt.Rows.Add(dw1);
DataRow dw2 = dt.NewRow();
dw2["name"] = "test2";
dt.Rows.InsertAt(dw2,0);
//將DataTable添加到DataSet中
ds.Tables.Add(dt);
//DataTable中查詢
DataTable dt = new DataTable();
DataRow dr[] = dt.Select("1 = 1");
//DataTable更新
DataTable dt = (DataTable)HttpContext.Current.Cache["MYCACHE"];
DataRow[] dr = dt.Select("1 = 1");
if (dr.Length > 0)
{
dr[0]["colName"] = "colValue";
}