我正在插入一个包含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_SI
和VAR_PART
然后= "ReturnValue
“
我也尝试在SI_KEY
和PART_NO
中将VAR_SI
和VAR_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