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

解决方案 »

  1.   

    不好意思,赋值语句写错了,应为    
        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
    这都不重要,关键是如何解决后面的分号问题?
      

  2.   

    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
      

  3.   

    晕了,一小段程序写错好几个地方。还是严谨点吧。
        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
      

  4.   

    拜托,不要找我那一小段程序的毛病,如何解决后面分号的问题? SelStr =""'清空
    这句明显不能加,不然每次循环都清空了,出现笔误很正常,我已经加在外面了。
    我们不去讨论这些,谈关键的。
      

  5.   

    在oracle中执行批,不要用分号吗?
      

  6.   

    把 sql語句DEbug.print 出來,然後到數據庫中去執行!
    很快就會找出錯誤的!
      

  7.   

    楼上的方法我早试过了,在数据库中执行,语句后面有分号是可以的,但在程序中就有错误。我的数据库调试工具是toad.
      

  8.   

    一次插入多條語句,sql server2000是可以的,但Access2000不可以
      

  9.   

    sql server2000用union 語句insert into tb(a,b)
    select 'aa','rrr'
    union select 'asdfsdf','asdwerwe'
    union ......
      

  10.   

    to hdhai9451(New New People---新新人类) :
    哎呀,我开始没在意你的方法,刚才不经意间看了一下。
    你这曲线救国的方法真是有新意啊,哈哈,确实可以办到。长见识了。