Fabian Frenademez
Fabian Frenademez

Reputation: 21

vb.net Oracle Insert with parameters (ORA-00936: missing expression)

i would like to use oracle parameters to insert data into the oracle db. i do the same in with sql server and it works fine. But with oracle i always get the ORA-00936: missing expression exception on the oCom.ExecuteNonQuery.

thanks for answers.. here is my vb.net code.

Using connOMS = New OracleConnection(connectionStringOMS)
Try
    connOMS.Open()

    Dim cmdstr As String = "INSERT INTO ARCHIVE_FEEDBACK(STATUS) VALUES(@STATUS)"

    Using Ocom As OracleCommand = New OracleCommand(cmdstr, connOMS)
        Dim p As OracleParameter
        p = New OracleParameter()
        p.Direction = ParameterDirection.InputOutput
        p.OracleDbType = OracleDbType.Varchar2
        p.ParameterName = "@STATUS"
        p.Value = "A"
        Ocom.Parameters.Add(p)

        Dim iRet As Integer = Ocom.ExecuteNonQuery
        If iRet > 0 Then
            Return True
        Else
            Return False
        End If
    End Using

    Catch ex As ApplicationException
        '...
    Catch orex As OracleException
        '...
    Finally

End Try

End Using

Upvotes: 2

Views: 3891

Answers (1)

Ed Gibbs
Ed Gibbs

Reputation: 26343

For Oracle, you need to use a colon (:) rather than the "at" sign (@) to indicate a parameter:

Dim cmdstr As String = "INSERT INTO ARCHIVE_FEEDBACK(STATUS) VALUES(:STATUS)"

and later on...

p.ParameterName = ":STATUS"

Upvotes: 3

Related Questions