Public adoCon As New ADODB.Connection
Public Cmd As New ADODB.Command
Public adoRecordset As New ADODB.Recordset strConnectString = "Provider=MSDAORA.1;Password=" & strPwd & _
";User ID=" & strUid & _
";Data Source=" & servername & _
";Persist Security Info=True"
adoCon.ConnectionString = strConnectString
adoCon.ConnectionTimeout = 100
adoCon.Open strConnectString Set Cmd.ActiveConnection = adoCon SelStr = " insert into " & ResolveTable("temp_for_bom")
SelStr = SelStr & " values " & "(" & out_arr(i).bkc_cd & "," & out_arr(i).child_item_cd & "," & out_arr(i).child_defect_pct & "," & out_arr(i).usage_dec & ")" Cmd.CommandText = SelStr
Set adoRecordset = Cmd.Execute
这样写没问题,但先在我把SelStr改成
SelStr = " insert into " & ResolveTable("temp_for_bom")
SelStr = SelStr & " values " & "(" & out_arr(i).bkc_cd & "," & out_arr(i).child_item_cd & "," & out_arr(i).child_defect_pct & "," & out_arr(i).usage_dec & ");"
在插入语句后加了个分号,就出现“ORA-00911无效字符”错误。数据库是oracle,我想用如下语句,给SelStr赋值,再一次性执行,但出现上面的错误,不知该如何解决。谢谢。
For i = 0 To j
SelStr = " insert into temp_for_bom"
SelStr = SelStr & " values " & "(" & out_arr(i).bkc_cd & "," & out_arr(i).child_item_cd & "," & out_arr(i).child_defect_pct & "," & out_arr(i).usage_dec & ");"
i = i + 1
Next i
Public Cmd As New ADODB.Command
Public adoRecordset As New ADODB.Recordset strConnectString = "Provider=MSDAORA.1;Password=" & strPwd & _
";User ID=" & strUid & _
";Data Source=" & servername & _
";Persist Security Info=True"
adoCon.ConnectionString = strConnectString
adoCon.ConnectionTimeout = 100
adoCon.Open strConnectString Set Cmd.ActiveConnection = adoCon SelStr = " insert into " & ResolveTable("temp_for_bom")
SelStr = SelStr & " values " & "(" & out_arr(i).bkc_cd & "," & out_arr(i).child_item_cd & "," & out_arr(i).child_defect_pct & "," & out_arr(i).usage_dec & ")" Cmd.CommandText = SelStr
Set adoRecordset = Cmd.Execute
这样写没问题,但先在我把SelStr改成
SelStr = " insert into " & ResolveTable("temp_for_bom")
SelStr = SelStr & " values " & "(" & out_arr(i).bkc_cd & "," & out_arr(i).child_item_cd & "," & out_arr(i).child_defect_pct & "," & out_arr(i).usage_dec & ");"
在插入语句后加了个分号,就出现“ORA-00911无效字符”错误。数据库是oracle,我想用如下语句,给SelStr赋值,再一次性执行,但出现上面的错误,不知该如何解决。谢谢。
For i = 0 To j
SelStr = " insert into temp_for_bom"
SelStr = SelStr & " values " & "(" & out_arr(i).bkc_cd & "," & out_arr(i).child_item_cd & "," & out_arr(i).child_defect_pct & "," & out_arr(i).usage_dec & ");"
i = i + 1
Next i
For i = 0 To j
SelStr = SelStr & " insert into temp_for_bom"
SelStr = SelStr & " values " & "(" & out_arr(i).bkc_cd & "," & out_arr(i).child_item_cd & "," & out_arr(i).child_defect_pct & "," & out_arr(i).usage_dec & ");"
i = i + 1
Next i
这都不重要,关键是如何解决后面的分号问题?
SelStr =""'清空
SelStr = " insert into temp_for_bom"
SelStr = SelStr & " values " & "(" & out_arr(i).bkc_cd & "," & out_arr(i).child_item_cd & "," & out_arr(i).child_defect_pct & "," & out_arr(i).usage_dec & ");"
i = i + 1
Next i
For i = 0 To j
SelStr = SelStr & " insert into temp_for_bom"
SelStr = SelStr & " values " & "(" & out_arr(i).bkc_cd & "," & out_arr(i).child_item_cd & "," & out_arr(i).child_defect_pct & "," & out_arr(i).usage_dec & ");"
Next i
这句明显不能加,不然每次循环都清空了,出现笔误很正常,我已经加在外面了。
我们不去讨论这些,谈关键的。
很快就會找出錯誤的!
select 'aa','rrr'
union select 'asdfsdf','asdwerwe'
union ......
哎呀,我开始没在意你的方法,刚才不经意间看了一下。
你这曲线救国的方法真是有新意啊,哈哈,确实可以办到。长见识了。