I'm using Oracle database. I have a table called Room
and then I made this stored procedure:
CREATE OR REPLACE PROCEDURE RETRIEVEROOM
(RoomID IN INTEGER, RID_Out OUT INTEGER)
AS
BEGIN
Select Room.RoomNumber INTO RID_Out
From Room
Where Room.RoomNumber = RoomID;
END;
So I'm trying to send input and output parameters using C# with this code:
private void loadRooms()
{
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "RETRIEVEROOM";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("RoomID", 218); // Here I send the input parameter
cmd.Parameters.Add("RID_Out", "").Direction = ParameterDirection.Output;
cmd.Parameters["RID_Out"].Size = 255;
cmd.ExecuteNonQuery();
MessageBox.Show(cmd.Parameters["RID_Out"].ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
When I try to print the value of output parameter
in the MessageBox, It prints "RID_Out" not the value of RID_Out
which should be 218
. How can I solve this problem?
Guess you want to print Value property of the parameter.
MessageBox.Show((string)cmd.Parameters["RID_Out"].Value, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.