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?