设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 5522|回复: 5
打印 上一主题 下一主题

[帮助] 请问用SQL语句怎么把一个TXT文件导入到ACCESS表中

[复制链接]
1#
发表于 2014-12-8 17:27:30 | 显示全部楼层
下面是我的实际例子,希望对你有帮助。

  Open "D:\work\grade1\student.txt" For Input As intFreeFileNumber
    If EOF(intFreeFileNumber) = False Then

        Do While EOF(intFreeFileNumber) = False

            Line Input #intFreeFileNumber, strRecord
            strCardID = Left(strRecord, 6)
            strPeopleNo = CS(DLookup("员工代号", "N-基本资料单头", "刷卡卡号='" & strCardID & "'and 是否离职='0'and 须刷卡否='1' and 指纹考勤='0' "))
            strDate = Format(Mid(strRecord, 7, 8), "0000/00/00")
            strTime = Format(Right(strRecord, 6), "00:00:00")
            strDateTime = Format(strDate & " " & strTime, "yyyy/mm/dd HH:mm:ss")

            cmm.CommandText = "Insert [N-刷卡钟数据表] (刷卡卡号,员工代号,日期,时间,完整时间,采集日期) " & _
                              "Values ('" & strCardID & "','" & strPeopleNo & "','" & strDate & "'," & _
                              "'" & strTime & "','" & strDateTime & "','" & Date & "')"
            cmm.Execute
            iRecordCount = iRecordCount + 1
            Call ProgressBar(20)
        Loop
        SysCmd acSysCmdClearStatus
    Else
        MsgBox "您所选择的文件没有任何刷卡资料!请查核后再继续下一步!", vbCritical
    End If
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-17 08:58 , Processed in 0.085823 second(s), 23 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表