zoukankan      html  css  js  c++  java
  • excel导入数据库的代码

    excel导入数据库的代码   
                 try
                {
                
                    OleDbDataReader dr1 = OAConfig1.MyReaderexcel("/source_file.xls","00",3,"SELECT * FROM [空间$]");
                   if(dr1.Read())
                   {
                      do
                      {
                         string ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("/targetdb.mdb")+";Jet OLEDB:Database Password=;"; 
                         OleDbConnection Connother = new OleDbConnection(ConnString);
                            if (Connother.State == ConnectionState.Closed)Connother.Open();
                      OleDbCommand  MyComm=new OleDbCommand("insert into 空间 (A,B,C,D,E,F,G)  values ('"+dr1[0].ToString()+"','"+dr1[1].ToString()+"','"+dr1[2].ToString()+"','"+dr1[3].ToString()+"','"+dr1[4].ToString()+"','"+dr1[5].ToString()+"','"+dr1[6].ToString()+"')", Connother);   
                         MyComm.ExecuteNonQuery();
                         MyComm.Dispose();
                      Connother.Close();
                      }while(dr1.Read());
                      
                   }
                   else
                   {
                     Response.Write("此Excel表是空的");
                   }
                    dr1.Close();
                }
                finally
                {
                
                OAConfig1.CloseConnexcel();
                
                }
                  Response.Write("此Excel导入ACCESS成功");
             
          }

  • 相关阅读:
    ChibiOS/RT 2.6.9 CAN Low Level Driver for STM32
    ChibiOS/RT 2.6.9 CAN Driver
    STM32F4 Alternate function mapping
    Spartan6 slave SelectMap configuration fails owing to JTAG?
    STM32F4: Generating parallel signals with the FSMC
    STM32F4xx -- Cortex M4
    STM32F4 HAL Composite USB Device Example : CDC + MSC
    AT91 USB Composite Driver Implementation
    USB组合设备 Interface Association Descriptor (IAD)
    MDK5 and STM32Cube
  • 原文地址:https://www.cnblogs.com/pretty/p/1276626.html
Copyright © 2011-2022 走看看