• C#批量将数据插入SQLServer数据库


                     Database db = CreateDatabase();
                    var varConnnection = db.CreateConnection();     //获取连接字符串对象
                    SqlBulkCopy sqlBulkcopy = new SqlBulkCopy(varConnnection.ConnectionString);
                    sqlBulkcopy.DestinationTableName = "T_ACl_User_Function";   //数据库表名字
                    sqlBulkcopy.BatchSize = dt.Rows.Count;
                    try
                    {
                        varConnnection.Open();
                        if (dt != null && dt.Rows.Count != 0)
                        {
                            sqlBulkcopy.WriteToServer(dt);  //批量插入到数据库中
                            init = 1;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        varConnnection.Close();
                        if (sqlBulkcopy != null)
                            sqlBulkcopy.Close();
                    }
                    return init;

  • 相关阅读:
    3.1按钮
    2.1线性布局
    2.2相对布局
    1.4Activity保存现场状态
    1.1Activity跳转与传值
    1.2Activity返回值
    1.3Activity生命周期
    WebSocket
    Jms消费者模式
    课堂实践5-31
  • 原文地址:https://www.cnblogs.com/leaflife/p/7000941.html
Copyright © 2020-2023  润新知