• c# 的导入功能SqlBulkCopy


    private static void DataTableToSQLServer( DataTable dt)
    {
    string connectionString = GetConnectionString();

    using (SqlConnection destinationConnection =new SqlConnection(connectionString))
    {
    destinationConnection.Open();

    using (SqlBulkCopy bulkCopy =new SqlBulkCopy(destinationConnection))
    {


    try
    {

    bulkCopy.DestinationTableName = "T_EIInformation";//要插入的表的表明
    bulkCopy.ColumnMappings.Add("Email", "Email");//映射字段名 DataTable列名 ,数据库 对应的列名
    bulkCopy.ColumnMappings.Add("author", "author");
    bulkCopy.ColumnMappings.Add("Title", "Title");
    bulkCopy.ColumnMappings.Add("Type", "Type");
    bulkCopy.ColumnMappings.Add("confName", "confName");
    bulkCopy.ColumnMappings.Add("Language", "Language");
    bulkCopy.ColumnMappings.Add("Publicationyear", "Publicationyear");
    bulkCopy.ColumnMappings.Add("Conferencelocation", "Conferencelocation");
    bulkCopy.WriteToServer(dt);
    }
    catch (Exception ex)
    {
    Console.WriteLine(ex.Message);
    }
    finally
    {
    // Close the SqlDataReader. The SqlBulkCopy
    // object is automatically closed at the end
    // of the using block.

    }
    }


    }

    }

  • 相关阅读:
    es6之class继承
    es6-class基本语法
    vue-cli3搭建pwa项目(一)
    vue 组件的通信方式
    react之组件&props
    React之元素渲染
    JSX
    JSX
    在项目中怎么使用react
    认识react
  • 原文地址:https://www.cnblogs.com/muxueyuan/p/4389101.html
Copyright © 2020-2023  润新知