I have this hotel reservation system, There is a dropdownlist which the user chooses their number of rooms on an specific room type to be reserved. Here is my Table_Room where I will get the Room ID to be inserted on Table_MyCart
Room_ID | Room_Type | Username | Arrival_Date | Departure_Date | Status
--------|-----------|----------|--------------|----------------|-------
CI-1 |Carneros |myuser |date |date |Available
CI-2 |Carneros |myuser |date |date |Available
My current code only gets the first Room_ID which is (CI-1) but what if the user used the dropdownlist and chose 2 rooms for the current type? How would I get the Room_ID (CI-2)? Here is my current code:
roomtype = "Carneros Inn";
SqlCommand cmd = new SqlCommand("FindRoom", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@ROOM_TYPE", SqlDbType.VarChar).Value = roomtype;
conn.Open();
cmd.ExecuteNonQuery();
roomid = cmd.ExecuteScalar().ToString();
conn.Close();
My Sql Code for the FindRoom StoredProcedure is this:
CREATE PROCEDURE [dbo].[FindRoom]
@ROOM_TYPE VARCHAR (20)
AS
SELECT ROOM_ID FROM TBL_Room
WHERE ROOM_TYPE = @ROOM_TYPE AND STATUS = 'AVAILABLE';
Any help would be appreciated