ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 513|回复: 0

插入数据出现自动化错误

[复制链接]

TA的精华主题

TA的得分主题

发表于 2018-8-3 10:57 | 显示全部楼层 |阅读模式
部门需要一个表,这个表字段很多,我也是检查过了,但不知道为什么会发生自动化错误,拜托大神帮忙看一看问题出现在哪里了 数据库1.PNG
数据库2.PNG
数据库3.PNG
数据库4.PNG

  1. mycolumn = "(ID,traName,conNum,fConNum,orderNum,conName,inveAmount,conAmount,paperTime,backTime,finalAmount,inAmount,certainTime,invoAmoDetail,invoAmoSum,invoTime,fundAmount,fundTime,compute1,compute2,compute3,compute4,compute5,profession,represent,pricipal,onlineTime,age,reason,fileTime,inBudget,fundBudget,actFinish,Jan,Feb,Mar,Apr,May,June,July,Aug,Sept,Oct,Dec,addupAmount,fPercent,listName)"
  2. myStr = "values("
  3. myStr = myStr & "" & Cells(4, 1) & ",'" & Cells(4, 2) & "','" & Cells(4, 3) _
  4.                 & "','" & Cells(4, 4) & "','" & Cells(4, 5) & "','" & Cells(4, 6) & "'," & Cells(4, 7) & "," & Cells(4, 8) & ",'" & Cells(4, 9) & "','" & Cells(4, 10) & "'," & Cells(4, 11) & "," & Cells(4, 12) & ",'" & Cells(4, 13) & "', '" & Cells(4, 14) & "', '" & Cells(4, 15) & "','" & Cells(4, 16) & "'," & Cells(4, 17) & ",'" & Cells(4, 18) & "'," & Cells(4, 19) & "," & Cells(4, 20) & "," & Cells(4, 21) & "," & Cells(4, 22) & "," & Cells(4, 23) & ",'" & Cells(4, 24) & "','" & Cells(4, 25) & "','" & Cells(4, 26) _
  5.                 & "','" & Cells(4, 27) & "','" & Cells(4, 28) & "','" & Cells(4, 29) & "','" & Cells(4, 30) & "'," & Cells(4, 31) & "," & Cells(4, 32) & "," & Cells(4, 33) & "," & Cells(4, 34) & "," & Cells(4, 35) & "," & Cells(4, 36) & "," & Cells(4, 37) & "," & Cells(4, 38) & "," & Cells(4, 39) & "," & Cells(4, 40) & "," & Cells(4, 41) & "," & Cells(4, 42) & "," & Cells(4, 43) & "," & Cells(4, 44) _
  6.                 & "," & Cells(4, 45) & "," & Cells(4, 46) & "," & Cells(4, 47) & ",'" & Cells(4, 48) & "')"
  7. Sql = "insert into list " & mycolumn & " " & myStr
  8. cnn.Execute Sql
复制代码



您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-9-28 11:21 , Processed in 0.036413 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

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