只从Oracle获取字符串“ReturnValue”而不是实际值

时间:2017-03-17 10:58:16

标签: vb.net oracle oledbcommand

我正在插入一个包含2列的表,这些列在插入表时会触发值。

我正在努力让这两个回报得到回报,而我回来的唯一一件事是"ReturnValue"

Dim query As String = "insert into SHOP_HEADER (CATEGORY, DESCRIPTION, CONSUMABLE) values (?,?,?) RETURNING SI_KEY, PART_NO INTO :VAR_SI, :VAR_PART"

Using Conn As New OleDbConnection(ConnectionStringToORACLE)
    Using CMD As New OleDbCommand()
        With CMD
            .Connection = Conn
            .CommandType = CommandType.Text
            .CommandText = query

            .Parameters.AddWithValue("CATEGORY", ListBox.SelectedValue)
            .Parameters.AddWithValue("DESCRIPTION", txtDescription.Text)
            .Parameters.AddWithValue("CONSUMABLE", "0")
            .Parameters.AddWithValue("SI_KEY", ParameterDirection.ReturnValue)
            .Parameters.AddWithValue("PART_NO", ParameterDirection.ReturnValue)

        End With
        Conn.Open()
        CMD.ExecuteNonQuery()
        VAR_SI = (CMD.Parameters("SI_KEY").Value.ToString)
        VAR_PART = (CMD.Parameters("PART_NO").Value.ToString)
    End Using
End Using

VAR_SIVAR_PART然后= "ReturnValue

我也尝试在SI_KEYPART_NO中将VAR_SIVAR_PART更改为CMD.Parameters.Parameters.AddWithValue以及相同的结果

更新工作

这是我最终做的事情,它现在有效。

Dim SIparam As New OleDbParameter()
SIparam.ParameterName = "VAR_SI"
SIparam.DbType = System.Data.DbType.Int32
SIparam.Direction = System.Data.ParameterDirection.Output

Dim PARTparam As New OleDbParameter()
MTIparam.ParameterName = "VAR_PART"
MTIparam.DbType = System.Data.DbType.Int32
MTIparam.Direction = System.Data.ParameterDirection.Output

Dim query As String = "insert into SHOP_HEADER (CATEGORY, DESCRIPTION, CONSUMABLE) values (?,?,?) RETURNING SI_KEY, PART_NO INTO :VAR_SI, :VAR_PART"

Using Conn As New OleDbConnection(ConnectionStringToORACLE)
    Using CMD As New OleDbCommand()
        With CMD
            .Connection = Conn
            .CommandType = CommandType.Text
            .CommandText = query

            .Parameters.AddWithValue("CATEGORY", ListBox.SelectedValue)
            .Parameters.AddWithValue("DESCRIPTION", txtDescription.Text)
            .Parameters.AddWithValue("CONSUMABLE", "0")
            .Parameters.Add(SIparam)
            .Parameters.Add(MTIparam)

        End With
        Conn.Open()
        CMD.ExecuteNonQuery()
        VAR_SI = (SIparam.Value)
        VAR_PART = (MTIparam.Value)
    End Using
End Using

0 个答案:

没有答案