zoukankan      html  css  js  c++  java
  • oracle批量导入数据

    关键代码

    OracleDataAdapter da=new OracleDataAdapter();
                    string sql_select = string.Format("select id,dt_date,dt_time,dt_hours from {0}", biao);
                    string sql_insert = string.Format("insert into {0} (id,dt_date,dt_time,dt_hours) values(:id,:dt_date,:dt_time,:dt_hours)", biao);
                    da.SelectCommand = new OracleCommand(sql_select, oraCon);
                    da.InsertCommand = new OracleCommand(sql_insert, oraCon);
                    da.InsertCommand.Parameters.Add(":id",OracleType.VarChar,32,"id");
                    da.InsertCommand.Parameters.Add(":dt_date",OracleType.Number,8,"dt_date");
                    da.InsertCommand.Parameters.Add(":dt_time",OracleType.Number,5,"dt_time");
                    da.InsertCommand.Parameters.Add(":dt_hours",OracleType.Number,5,"dt_hours");
                    da.InsertCommand.UpdatedRowSource = System.Data.UpdateRowSource.None;
                    da.UpdateBatchSize=0;
                    DataSet ds=new DataSet();
                    da.Fill(ds);
                    int dt_hours = -3;
                    #region 
                    for (int j = 0; j < 75/3;j++ )
                    {
                        dt_hours = dt_hours + 3;
                        for (int i = 0; i < 25600; i++)
                        {
                            Guid guid = System.Guid.NewGuid();
                            Object[] row = { guid, sjint, 8, dt_hours };
                            ds.Tables[0].Rows.Add(row);
                            if (i % 400 == 0)
                            {
                                da.Update(ds.Tables[0]);
                                ds.AcceptChanges();
                                ds.Tables[0].Clear();
                            }
                        }
                        da.Update(ds.Tables[0]);
                        ds.AcceptChanges();
                        ds.Tables[0].Clear();
                        dt_hours = -3;
                    }
                    for (int j = 0; j < 75 / 3; j++)
                    {
                        dt_hours = dt_hours + 3;
                        for (int i = 0; i < 25600; i++)
                        {
                            Guid guid = System.Guid.NewGuid();
                            Object[] row = { guid, sjint,20, dt_hours };
                            ds.Tables[0].Rows.Add(row);
                            if (i % 400 == 0)
                            {
                                da.Update(ds.Tables[0]);
                                ds.AcceptChanges();
                                ds.Tables[0].Clear();
                            }
                        }
                        da.Update(ds.Tables[0]);
                        ds.AcceptChanges();
                        ds.Tables[0].Clear();
                        dt_hours = -3;
                    }
                    #endregion 
                    da.Dispose();
                    ds.Dispose();
                    oraCon.Close();
                    this.button2.Enabled = true;
    

      

  • 相关阅读:
    梦断代码阅读笔记03
    第十二周进度条
    找“水王”
    梦断代码阅读笔记02
    梦断代码阅读笔记01
    团队开发第二阶段个人博客(2)
    团队开发第二阶段个人博客(1)
    个人总结
    第16周学习进度条
    个人进度条第15周
  • 原文地址:https://www.cnblogs.com/bobo-show/p/4901606.html
Copyright © 2011-2022 走看看