我在Access 2010中使用后端JET数据库,将值插入该数据库。
这不会插入数据库(没有返回错误消息)
insert into [PROJECT RESOURCE UPDATE HISTORY] ([Current Date], [Project Auto No Ref], [Resource ID Ref], [Allocation Notes], [Allocation Role],[Usage Percentage - Oct], [Usage Percentage - Nov], [Usage Percentage - Dec], [Usage Percentage - Jan], [Usage Percentage - Feb], [Usage Percentage - Mar], [Usage Percentage - Apr], [Usage Percentage - May],[Usage Percentage - Jun], [Usage Percentage - Jul], [Usage Percentage - Aug], [Usage Percentage - Sep] ) values (#2/13/2017 11:01:41 AM#, 540,11,'','Project Manager',0,1,1,1,1,1,1,0,0,0,0,0)
但这确实
insert into [PROJECT RESOURCE UPDATE HISTORY] ([Current Date], [Project Auto No Ref], [Resource ID Ref], [Allocation Notes], [Allocation Role],[Usage Percentage - Oct], [Usage Percentage - Nov], [Usage Percentage - Dec], [Usage Percentage - Jan], [Usage Percentage - Feb], [Usage Percentage - Mar], [Usage Percentage - Apr], [Usage Percentage - May],[Usage Percentage - Jun], [Usage Percentage - Jul], [Usage Percentage - Aug], [Usage Percentage - Sep] ) values (#2/13/2017 11:04:38 AM#, 540,821,'','DevOps',0,0.13,0.13,0.13,0.13,0.13,0.13,0,0,0,0,0)
以下是执行实际插入的代码片段
sqlStatement2 = "insert into [PROJECT RESOURCE UPDATE HISTORY] (" & _ "[Current Date], [Project Auto No Ref], [Resource ID Ref], [Allocation Notes], [Allocation Role]," & _ "[Usage Percentage - Oct], [Usage Percentage - Nov], [Usage Percentage - Dec], [Usage Percentage - Jan]," & _ "[Usage Percentage - Feb], [Usage Percentage - Mar], [Usage Percentage - Apr], [Usage Percentage - May]," & _ "[Usage Percentage - Jun], [Usage Percentage - Jul], [Usage Percentage - Aug], [Usage Percentage - Sep] " & _ ") values (" & _ "#" & Now() & "#," & _ rst![Current Project Ref No] & "," & rst![Current Resource Person ID] & ",'" & rst![Current Allocation Notes] & _ "','" & rst![Current Allocation Role] & "'," & CDbl(oct) & "," & CDbl(nov) & "," & CDbl(dec) & _ "," & CDbl(jan) & "," & CDbl(feb) & "," & CDbl(mar) & "," & CDbl(apr) & _ "," & CDbl(may) & "," & CDbl(jun) & "," & CDbl(jul) & "," & CDbl(aug) & _ "," & CDbl(sep) & ");" MsgBox (sqlStatement2) CurrentDb.Execute (sqlStatement2) rst.MoveNext
我认为问题围绕在第一个示例中将1插入数据库。数据库不报告错误,并且不显示该行。如果将值从1更改为0.99,则插入正常并显示在数据库中。 我尝试过的事情和观察结果:
在我在vba代码中执行insert语句之前,我还尝试使用CDbl()函数手动将1转换为double。
如果我在第一次插入后使用值1中断代码,则行ID将跳过下一个值,就像插入行一样
我还能在哪儿看?
答案 0 :(得分:0)
数据库不报告错误,并且不显示该行。
那是因为could not find or load main class
方法的默认行为是
oracle-java8-jdk is already the newest version
如果查询遇到困难,将避免抛出错误。你应该使用
.Execute
所以CurrentDb.Execute (sqlStatement2) ' with no second argument
可以告诉你为什么INSERT不成功。