Public Sub InsertERP()
        Dim oraclestr As New StringBuilder
        oraclestr.AppendLine("Create SEQUENCE DATE_SEQ")
        oraclestr.AppendLine("minvalue 0")
        oraclestr.AppendLine("maxvalue 99999")
        oraclestr.AppendLine("start with 1")
        oraclestr.AppendLine("increment by 1")
        oraclestr.AppendLine("nocache")
        oraclestr.AppendLine("cycle;")
        oraclestr.AppendLine("Insert into ZMES_INV_MTL_TXNS (TXN_ID,ORGANIZATION_ID,SOURCE_CODE,COMPONENT_ITEM,COMPONENT_ITEM_UOM,TRANSACTION_TYPE_ID,SUBINVENTORY_CODE,TRANSACTION_DATE,TRANSACTION_QUANTITY,PROCESS_FLAG,CREATION_DATE) Values (TO_CHAR(SYSDATE,'YYYYMM')||LPAD(TO_CHAR(DATE_SEQ.NEXTVAL),4,'0'),185,'" + Me.txtNum.Text + "','X00000001','KG',354,'XFMS',SYSDATE,'" + Me.txtTW.Text + "','N',SYSDATE)")
        Dim oracleConn As New OracleConnection(ConfigurationManager.ConnectionStrings("ERPConnectionString").ConnectionString)
        Dim oracleCmd As New OracleCommand(oraclestr.ToString(), oracleConn)
        If oracleConn.State = ConnectionState.Closed Then
            oracleConn.Open()
        End If
        oracleCmd.ExecuteNonQuery()
        oracleCmd.Dispose()
        oracleConn.Close()
    End Sub
运行时提示:ORA-00911:麻烦大家帮忙看看问题错在哪里,可能出错在自动编号中,分给的不多,麻烦大家了,谢谢

解决方案 »

  1.   

    oraclestr里的变量,符号;多了?
    oraclestr.AppendLine("cycle;") 
    去掉;试试
      

  2.   

    应该有提示是哪一行的?ORA-00911 invalid characterCause: Special characters are valid only in certain places. If special characters other than $, _, and # are used in a name and the name is not enclosed in double quotation s ("), this message will be issued. One exception to this rule is for database names; in this case, double quotes are stripped out and ignored.Action: Remove the invalid character from the statement or enclose the object name in double quotation s.注意一下符号?
      

  3.   


    去掉;后,提示,ORA-00933:SQL的命令结束有问题
      

  4.   

     oraclestr.AppendLine("Insert into ZMES_INV_MTL_TXNS (TXN_ID,ORGANIZATION_ID,SOURCE_CODE,COMPONENT_ITEM,COMPONENT_ITEM_UOM,TRANSACTION_TYPE_ID,SUBINVENTORY_CODE,TRANSACTION_DATE,TRANSACTION_QUANTITY,PROCESS_FLAG,CREATION_DATE) Values (TO_CHAR(SYSDATE,'YYYYMM')||LPAD(TO_CHAR(DATE_SEQ.NEXTVAL),4,'0'),185,'" + Me.txtNum.Text + "','X00000001','KG',354,'XFMS',SYSDATE,'" + Me.txtTW.Text + "','N',SYSDATE)") 
    你再这里SYSDATE)") 加上;号SYSDATE);")
    你的调试的oraclestr值可以贴出来?这样看很难看出来
      

  5.   

    您好,按照您的说法做后,提示:
    ORA-00933: SQL 命令的結束有問題说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.OracleClient.OracleException: ORA-00933: SQL 命令的結束有問題
    源错误: 
    行 394:            oracleConn.Open()
    行 395:        End If
    行 396:        oracleCmd.ExecuteNonQuery()
    行 397:        oracleCmd.Dispose()
    行 398:        oracleConn.Close()
     源文件: c:\inetpub\wwwroot\nbflow\NBBJL\Default6.aspx.vb    行: 396 
      

  6.   

    你把你的oraclestr得到的调试值放到SQL执行工具里执行下,看成功不成功就知道了哪里错误了