//把List<string>转为DataTable
List<string> myList = new List<string>();
DataTable dt2 = new DataTable();
dt2.Columns.Add(new DataColumn("sqlString", typeof(string))); //给表dt2添加字段
DataRow dr;
foreach (var i in myList)
{
dr = dt2.NewRow(); //字段对象
dr["sqlString"] = i; //赋值
dt2.Rows.Add(dr); //添加给表
}

把List<string>转为DataTable的更多相关文章

  1. .NET(C#)中的DataSet、string、DataTable等对象转换成Json

    ConvertJson.cs类 using System; using System.Collections.Generic; using System.Text; using System.Data ...

  2. (C#)中的DataSet、string、DataTable等对象转换成Json

    ConvertJson.cs类 using System; using System.Collections.Generic; using System.Text; using System.Data ...

  3. .net 打开Excel文档并转为DataTable

    /// <summary> /// 打开Excel文档并转为DataTable /// </summary> /// <returns></returns&g ...

  4. DataTable.Select筛选过滤数据返回DataRow[]转为DataTable添加到DataSet

    问题还原,如图所示,我们要筛选所有SHDP 为北京翠微KR的数据. 1. 筛选DataTable微软为我们提供了一个方法DataTable.Select(),其用法如下: 1)  Select()—— ...

  5. [C#]List<int>转string[],string[]转为string

    // List<int>转string[] public string[] ListInt2StringArray(List<int> input) { return Arra ...

  6. C#中的DataSet、string、DataTable、对象转换成Json的实现代码

    C#中对象,字符串,dataTable.DataReader.DataSet,对象集合转换成Json字符串方法. public class ConvertJson { #region 私有方法 /// ...

  7. {}typeof string转为 obj json

    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.11.3/jquer ...

  8. 读取Excel里面的内容转为DataTable

    using System; using System.Collections.Generic; using System.Data; using System.Data.OleDb; using Sy ...

  9. C++ MFC std::string转为 std::wstring

    std::string转为 std::wstring std::wstring UTF8_To_UTF16(const std::string& source) { unsigned long ...

随机推荐

  1. 修改CentOS7网卡名称为传统名称eth0格式

    1.调整网卡名称 进入网卡目录```[root@tools]# cd/etc/sysconfig/network-scripts/``` 修改名称```[root@network-scripts]# ...

  2. Android Animation 动画

    动画类型 Android的animation由四种类型组成  Android动画模式 Animation主要有两种动画模式:一种是tweened animation(渐变动画) XML中 JavaCo ...

  3. 深入理解java虚拟机-第七章

    第7章 虚拟机类加载机制 类的加载的时机 加载 Loading, 连接 Linking(验证 Verfiication, 准备Preparation, 解析 Resolution) 初始化 Initi ...

  4. Hibernate HQL查询(2)

    hql是面向对象查询,格式:from + 类名 + 类对象 + where + 对象的属性 sql是面向数据库表查询,格式:from + 表名 + where + 表中字段 1.查询 一般在Hiber ...

  5. LeetCode Degree of an Array

    原题链接在这里:https://leetcode.com/problems/degree-of-an-array/description/ 题目: Given a non-empty array of ...

  6. gogs docker 安装

     1.  gogs 镜像      docker pull gogs/gogs    2.  mysql    docker mysql    3.  本地数据卷配置 mkdir gogs & ...

  7. 3 循环语句——《Swift3.0从入门到出家》

    3 循环语句 当一段代码被多次重复利用的使用我们就使用循环 swift提供了三种形式的循环语句 1.while 循环 2.repeat — while 循环 3.for — in 循环 while 循 ...

  8. Linux 服务器的那些性能参数指标

    一个基于 Linux 操作系统的服务器运行的同时,也会表征出各种各样参数信息.通常来说运维人员.系统管理员会对这些数据会极为敏感,但是这些参数对于开发者来说也十分重要,尤其当你的程序非正常工作的时候, ...

  9. List,ArrayList

    List是一个接口,而ListArray是一个类. ListArray继承并实现了List. 所以List不能被构造,但可以向上面那样为List创建一个引用,而ListArray就可以被构造. Lis ...

  10. 随时查找中位数——pat1057

    http://pat.zju.edu.cn/contests/pat-a-practise/1057 题目的意思是可以在一个可以任意添加于删除整数的集合里随时查找该集合的中位数 每次查找用nlogn的 ...