日期:2014-05-17  浏览次数:20867 次

ASP导入数据库时间问题,求解决。
以下源代码是一个考勤系统的导入数据库ASP程序,现在导入会有一个问题,就是只能导入日期最新的不同姓名的数据,重复姓名的导入不进去,而我想要实现的功能是把excel表中的数据全部导入到数据库了,请问应该怎么修改代码?

xlsdaokq.asp
JScript code
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!-- #include file="BGMConn.asp" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
        <title>导考勤数据程序</title>
    </head>
    <body>
        <% 


    Set excconn=Server.CreateObject("ADODB.Connection")  
   
      '  excStrConn= "Driver={Microsoft Excel Driver (*.xls)};DBQ="&request("file") 
     excpath=request("a1")
     excStrConn= "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(excpath) & ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1'" 

      
          excconn.Open  excStrConn
    
           '查询excel语句
    
           Set excrs = Server.CreateObject("ADODB.Recordset") 
     
           excSql="select * from [kq$]"
      
   
             excrs.Open excSql,excconn,2,2  
    
    set rs=server.createObject("ADODB.Recordset")
      
        
       do while Not excrs.EOF 
        
    flat = 0
        
    sql="select * from namesfz where name='"&excrs(0)&"'"
         
    set rs=server.createObject("ADODB.Recordset")
    rs.open sql,conn,1,1

                
                
    if not rs.EOF then '此用户存在
                
              
    'response.write  rs("id")
        
    'if not rs.eof  then
    'j=0
    sql1="select * from kq where name='"&rs("name")&"'"
            
    set rs1=server.CreateObject("adodb.recordset") 

        rs1.open sql1,conn,1,3 
 
                  
    do while Not rs1.EOF 
                  
if year(date())= year(rs1("chuqintime"))  and  month(rs1("chuqintime"))=month( year(date())&"-"&request("month_gz")&"-"&day(date()))  then
                     
        flat = 1          
                    
        for t_i=1  to  16
 
                   
        rs1(t_i+1) = excrs(t_i)
                                    
  
        next 
                                rs1("chuqintime") =( year(date())&"-"&request("month_gz")&"-"&day(date()))
                               rs1.update 
                             'response.write rs1(2)  
                       ' response.write "<script>alert('更新成功!');location.href='gzmanage.asp';<'/script>" 
        
        end if
                   
        rs1.movenext
        loop
                   
                   

             if flat<>1 then
             
                  rs1.addnew
  
                     for t=0 to 16
                  
                  rs1(t+1)=excrs(t)
  
                  next 
  
                  rs1("chuqintime") =( year(date())&"-"&request("month_gz")&"-"&day(date()))
 
                              
                 rs1.update 
                  
                 end if
                 
                 rs1.close 
                  
        set rs1=nothing 
                   
        '  response.write "<script>alert('添加成功!');location.href='gzmanage.asp';</'script>" 
            
                
        else  '此用户不存在
                 
        sql="select * from cunzainame "