//创建 表
DataTable tables = new DataTable();
//添加 创建 列
//第一列
DataColumn cums = new DataColumn();
cums.ColumnName = "UserName";
cums.DataType = typeof(string);
tables.Columns.Add(cums);
cums = new DataColumn();
cums.ColumnName = "Age";
cums.DataType = typeof(string);
tables.Columns.Add(cums);
tables.Columns.Add("Address", typeof(string)); 这种用的较多
tables.Columns["Address"].SetOrdinal(0); //修改DataTable 列的顺序
string[] columnNames = GetColumnsByDataTable(tables);
string ss = columnNames[0];
        /// <summary>
/// 根据datatable获得列名
/// </summary>
/// <param name="dt">表对象</param>
/// <returns>返回结果的数据列数组</returns>
public string[] GetColumnsByDataTable(DataTable dt)
{
string[] strColumns = null;
if (dt.Columns.Count > 0)
{
int columnNum = 0;
columnNum = dt.Columns.Count;
strColumns = new string[columnNum];
for (int i = 0; i < dt.Columns.Count; i++)
{
strColumns[i] = dt.Columns[i].ColumnName;
}
}
return strColumns;
}

最新文章

  1. 详解Python中的循环语句的用法
  2. eclipse绘制activiti无法生成图形
  3. Python札记 -- 使用easy_install进行模块/包管理
  4. Linux内核加载全流程
  5. nyoj 811 变态最大值
  6. C# 调试程序弹出 没有可用于当前位置的源代码 对话框
  7. MySQL主主复制+LVS+Keepalived实现MySQL高可用性
  8. 由一道淘宝面试题到False sharing问题
  9. ECLIPSE JSP TOMCAT 环境搭建
  10. [翻译]初识SQL Server 2005 Reporting Services Part 1
  11. 怎样求FIRST集、FOLLOW集和SELECT集
  12. Codeforces Round #256 (Div. 2) B Suffix Structures
  13. CentOS-7.2安装SQuirreL SQL Client连接Hive
  14. Access数据库自动生成设计文档
  15. Flume报 Space for commit to queue couldn&#39;t be acquired. Sinks are likely not keeping up with sources, or the buffer size is too tight
  16. 知物由学 | 基于DNN的人脸识别中的反欺骗机制
  17. 手撸GitLab CI(阉割版)
  18. 2018-2019-2 20165302 《网络对抗技术》Exp3 免杀原理与实践
  19. Linux Shell常用技巧(三)
  20. 何时使用copy,strong,weak,assign关键字 定义属性

热门文章

  1. [Oracle/sql]查看当前用户名下有多少表 以及查看表字段信息
  2. Python算法题:有100只大、中、小骆驼,100框土豆,一只大骆驼可以背3框,中骆驼可以背俩框,小骆驼两只背一筐,问大中小各有多少只骆驼?
  3. Python爬虫学习第一记 (翻译小助手)
  4. adb安装apk包提示protocol failure问题
  5. Spring boot中配置HikariCP连接池
  6. Magento中数据拷贝一实现
  7. redis并发问题2
  8. 详尽的 Elasticsearch7.X 安装及集群搭建教程
  9. 面试的加分项:懂点 Nginx 反向代理与负载均衡
  10. VUE开发(一)Spring Boot整合Vue并实现前后端贯穿调用