我现在用的导入方法是:
string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1'";
            OleDbConnection ExcelConn = new OleDbConnection(strCon);
            try
            {
                string strCom = string.Format(sql);
                ExcelConn.Open();
                OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, ExcelConn);
                DataSet ds = new DataSet();
                myCommand.Fill(ds, "[" + tableName + "$]");
                ExcelConn.Close();
                ExcelConn.Dispose();
                return ds;
            }
            catch
            {
                ExcelConn.Close();
                ExcelConn.Dispose();
                return null;
            }
这种效率低 高手们有没其它的方法了!
因为是给客户用 所以大家不要说用什么自带的导入功能,只要代码的导入!

解决方案 »

  1.   


    create table #table (ID char(1),Name char(100))
     INSERT INTO #table
    select 1 as ID,'Nam1' as Name where not exists(select NULL from #table where ID=1)INSERT INTO #table
    select 2 as ID,'Nam2' as Name where not exists(select NULL from #table where ID=2)INSERT INTO #table
    select 3 as ID,'Nam3' as Name where not exists(select NULL from #table where ID=3)INSERT INTO #table
    select 4 as ID,'Nam2' as Name where not exists(select NULL from #table where ID=4)INSERT INTO #table
    select 5 as ID,'Nam2' as Name where not exists(select NULL from #table where ID=5)
    INSERT INTO #table
    select 5 as ID,'Nam2' as Name where not exists(select NULL from #table where ID=5)
    INSERT INTO #table
    select 5 as ID,'Nam2' as Name where not exists(select NULL from #table where ID=5)
    INSERT INTO #table
    select 5 as ID,'Nam2' as Name where not exists(select NULL from #table where ID=5)
    INSERT INTO #table
    select 5 as ID,'Nam2' as Name where not exists(select NULL from #table where ID=5)
    INSERT INTO #table
    select 5 as ID,'Nam2' as Name where not exists(select NULL from #table where ID=5)
    select * from #table
    drop table #table 
    改成oracel的试试
    这个是最好的导入方式,而且验证重复性
      

  2.   

    我导入一个excel需要6-7分钟,数据是6w多行
      

  3.   

    我导入一个excel需要6-7分钟,数据是6w多行
      

  4.   

    按你这的说我要 循环的拼接sql语句吗
      

  5.   

    一条语句
    一执行或者100条数据一执行,10000条数据一提交事务INSERT INTO #table
    select 1 as ID,'Nam1' as Name where not exists(select NULL from #table where ID=1)
      

  6.   

    1:sqlldr效率好 就是麻烦一点,得转换2:oracle的存储过程接受数组,也需要转换