DataColumn的Expression用法
//========================
DataColumn TotalPriceColumn = new DataColumn
("TotalPrice", System.Type.GetType("System.Double"));
TotalPriceColumn.Expression = ("Price * Quantity");
再把Column加到DataTable裡

設定DataColumn自動編號之起始編號與一次增加的量
//========================
SalesTable.Columns.Add("ID", Type.GetType("System.Int32"));
SalesTable.Columns["ID"].AutoIncrement = true;
SalesTable.Columns["ID"].AutoIncrementSeed =1;
SalesTable.Columns["ID"].AutoIncrementStep = 5;

允不允許為NULL
//=======================
myTable.Columns["ID"].AllowDBNull = false;

增加列
//======================
DataRow CustRow =myTable.NewRow();
Object[] myRecord = {
"1",
"2",
"3",
"welkingunther",
"1985",
"welkin",
null,
"10000",
"Taiwan",
"09090909",
"08080808"};
CustRow.ItemArray = myRecord;
myTable.Rows.Add(CustRow);

welkingunther 發表在 痞客邦 PIXNET 留言(0) 人氣()