.NET-DataColumn.DataType 属性
2024-09-02 23:26:52
public DataTable MakeDataTable(){ DataTable myTable;
DataRow myNewRow;
// Create a new DataTable.
myTable = new DataTable("My Table"); // Create DataColumn objects of data types.
DataColumn colString = new DataColumn("StringCol");
colString.DataType = System.Type.GetType("System.String");
myTable.Columns.Add(colString); DataColumn colInt32 = new DataColumn("Int32Col");
colInt32.DataType = System.Type.GetType("System.Int32");
myTable.Columns.Add(colInt32); DataColumn colBoolean = new DataColumn("BooleanCol");
colBoolean.DataType = System.Type.GetType("System.Boolean");
myTable.Columns.Add(colBoolean); DataColumn colTimeSpan = new DataColumn("TimeSpanCol");
colTimeSpan.DataType = System.Type.GetType("System.TimeSpan");
myTable.Columns.Add(colTimeSpan); DataColumn colDateTime = new DataColumn("DateTimeCol");
colDateTime.DataType = System.Type.GetType("System.DateTime");
myTable.Columns.Add(colDateTime); DataColumn colDecimal = new DataColumn("DecimalCol");
colDecimal.DataType = System.Type.GetType("System.Decimal");
myTable.Columns.Add(colDecimal); DataColumn colByteArray = new DataColumn("ByteArrayCol");
colByteArray.DataType = System.Type.GetType("System.Byte[]");
myTable.Columns.Add(colByteArray); // Populate one row with values.
myNewRow = myTable.NewRow(); myNewRow["StringCol"] = "Item Name";
myNewRow["Int32Col"] = ;
myNewRow["BooleanCol"] = true;
myNewRow["TimeSpanCol"] = new TimeSpan(,,,,);
myNewRow["DateTimeCol"] = System.DateTime.Today;
myNewRow["DecimalCol"] = 64.0021;
myNewRow["ByteArrayCol"] = new Byte[] { , , };
myTable.Rows.Add(myNewRow);
return myTable;
}
最新文章
- python基础04 运算
- You Don't Need jQuery
- hdu 4759 大数+找规律 ***
- 【CodeVS】 p1225 八数码难题
- Yii 框架表单验证---实例
- linux OpenOffice
- QT 让窗口(或控件)居中
- poj2478--欧拉函数打表
- 给Linux添加google搜索命令
- 浅谈对象的两个方法:Object.keys() ,Object.assign();
- 怎么在父窗口调用它页面的iframe里面数据,进行操作?
- Putty Technical Note
- P1569 [USACO11FEB]属牛的抗议
- DALFactory有什么作用
- 最简单,有效的学习mysql教程(一)
- ";Hello World!";团队第十次会议
- bzoj 1110 贪心 + 进制转换
- 18 Command Line Tools to Monitor Linux Performance
- HDU 2648(搜索题,哈希表)
- Selenium之当鼠标悬浮时隐藏的元素才出现
热门文章
- 前端学习——css(初级)
- websocket小荔枝
- CentOS7.5安装配置conky(极简)
- html和url两种录制方式
- Codeforces 1082 D. Maximum Diameter Graph-树的直径-最长链-构造题 (Educational Codeforces Round 55 (Rated for Div. 2))
- 洛谷 P3384 【模板】树链剖分-树链剖分(点权)(路径节点更新、路径求和、子树节点更新、子树求和)模板-备注结合一下以前写的题目,懒得写很详细的注释
- MediaPlayer滑动不准的问题
- 一个菜鸟正在用SSH写一个论坛(1)
- leetcode88 Merged Sorted Array
- CodeForces - 524F And Yet Another Bracket Sequence