最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#編程實(shí)現(xiàn)DataTable添加行的方法

 更新時間:2015年11月16日 10:13:31   作者:Jan.David  
這篇文章主要介紹了C#編程實(shí)現(xiàn)DataTable添加行的方法,結(jié)合兩個實(shí)例形式分析了C#操作DataTable實(shí)現(xiàn)動態(tài)添加行的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實(shí)例講述了C#編程實(shí)現(xiàn)DataTable添加行的方法。分享給大家供大家參考,具體如下:

方法一:

DataTable tblDatas = new DataTable("Datas");
DataColumn dc = null;
dc = tblDatas.Columns.Add("ID", Type.GetType("System.Int32"));
dc.AutoIncrement = true;//自動增加
dc.AutoIncrementSeed = 1;//起始為1
dc.AutoIncrementStep = 1;//步長為1
dc.AllowDBNull = false;//
dc = tblDatas.Columns.Add("Product", Type.GetType("System.String"));
dc = tblDatas.Columns.Add("Version", Type.GetType("System.String"));
dc = tblDatas.Columns.Add("Description", Type.GetType("System.String"));
DataRow newRow;
newRow = tblDatas.NewRow();
newRow["Product"] = "水果刀";
newRow["Version"] = "2.0";
newRow["Description"] = "打架專用";
tblDatas.Rows.Add(newRow);
newRow = tblDatas.NewRow();
newRow["Product"] = "折疊凳";
newRow["Version"] = "3.0";
newRow["Description"] = "行走江湖七武器之一";
tblDatas.Rows.Add(newRow);

方法二:

DataTable tblDatas = new DataTable("Datas");
tblDatas.Columns.Add("ID", Type.GetType("System.Int32"));
tblDatas.Columns[0].AutoIncrement = true;
tblDatas.Columns[0].AutoIncrementSeed = 1;
tblDatas.Columns[0].AutoIncrementStep = 1;
tblDatas.Columns.Add("Product", Type.GetType("System.String"));
tblDatas.Columns.Add("Version", Type.GetType("System.String"));
tblDatas.Columns.Add("Description", Type.GetType("System.String"));
tblDatas.Rows.Add(new object[]{null,"a","b","c"});
tblDatas.Rows.Add(new object[] { null, "a", "b", "c" });
tblDatas.Rows.Add(new object[] { null, "a", "b", "c" });
tblDatas.Rows.Add(new object[] { null, "a", "b", "c" });
tblDatas.Rows.Add(new object[] { null, "a", "b", "c" });

希望本文所述對大家C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論

芷江| 桦南县| 商河县| 大埔县| 乐业县| 汕头市| 蓬莱市| 陇西县| 逊克县| 郁南县| 伊宁市| 延寿县| 卢湾区| 东兴市| 蓬安县| 三原县| 青岛市| 武平县| 阳谷县| 金门县| 福鼎市| 平遥县| 农安县| 承德县| 子长县| 宁津县| 安宁市| 兰州市| 庄浪县| 安阳县| 浦东新区| 丰镇市| 玛沁县| 新郑市| 德化县| 合水县| 兴和县| 龙川县| 莱州市| 兴义市| 德安县|