ADO 读写文本文件

    ' 创建配置文件
   
   
    Open ThisWorkbook.Path & "\schema.ini" For Append As #1
   
        Print #1, "[table2.csv] "
        Print #1, "Format=CSVDelimited "
        Print #1, "ColNameHeader=False"
        Print #1, "MaxScanRows=0"
        Print #1, "Col1=工号   Text   Width   50  "
        Print #1, "Col2=姓名   Text   Width   50  "
        Print #1, "Col3=入职日期   DateTime"
        Print #1, "Col4=班别   Text   Width   50  "
        Print #1, "Col5=职位   Text   Width   50  "
        Print #1, "Col6=分值补贴   Single"
        Print #1, "Col7=计件分钟   Single"
        Print #1, "col8=上班分钟   Single"
        Print #1, "col9=效率   Single"
        Print #1, " "
        Print #1, "[table1.csv]"
        Print #1, "Format=CSVDelimited  "
        Print #1, "ColNameHeader=False"
        Print #1, "MaxScanRows=0"
        Print #1, "Col1=c1   Text   Width   50  "
        Print #1, "Col2=c2   Text   Width   50  "
        Print #1, "Col3=c3   Text   Width   50  "
        Print #1, "Col4=c4   Text   Width   50  "
        Print #1, "Col5=c5   Text   Width   50  "
        Print #1, "Col6=工号   Text   Width   50  "
        Print #1, "Col7=c7   Text   Width   50  "
        Print #1, "Col8=款号   Text   Width   50  "
        Print #1, "Col9=c9   Text   Width   50  "
        Print #1, "Col10=c10   Text   Width   50  "
        Print #1, "Col11=c11   Text   Width   50  "
        Print #1, "Col12=c12   Text   Width   50  "
        Print #1, "Col13=c13   Text   Width   50  "
        Print #1, "Col14=c14   Text   Width   50  "
        Print #1, "Col15=c15   Text   Width   50  "
        Print #1, "Col16=c16   Text   Width   50  "
        Print #1, "Col17=车种   Text   Width   50  "
      
   
    Close #1


    On Error Resume Next
   
    Dim cnn As New ADODB.Connection
    cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ThisWorkbook.Path & "\;Extended Properties='text;HDR=No;FMT=Fixed';"
   
    If cnn.State = 0 Then
        Set cnn = Nothing
        MsgBox ("数据库连接失败!")
        Exit Sub
    End If
   
    Dim rec As New ADODB.Recordset
   
    rec.Open "select distinct t2.*, (t1.c1 + '-' + t1.c2 + '-1') as 更新时间, t1.款号, t1.车种 from table2.csv as t2" _
        & " left join table1.csv as t1 on t1.工号 = t2.工号" _
        & " order by t2.职位, t2.班别, t2.工号, t1.款号", cnn

转载于:https://www.cnblogs.com/lbnnbs/p/4785011.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值