4 Replies - 481 Views - Last Post: 12 July 2019 - 10:04 AM Rate Topic: -----

#1 aimaishanu   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-July 19

Online Hotel Reservation system

Posted 11 July 2019 - 10:52 AM

//connection string
            SqlConnection con = new SqlConnection(connectionString);
           
                con.Open();
                //sql statement 

            // if roomstatus = 1 then the room is active else if room status = 0 then the room is vacant
                SqlCommand cmd = new SqlCommand("select roomstatus from Room where roomstatus != 1 ", con);

            //checks if the room is active or vacant, if yes pop up the message else proceed to reservation

        

           int roomstatus = int.Parse(cmd.ExecuteScalar().ToString());
    
            
            if(roomstatus == 0)
            {
                lbl2.Text = "Available Rooms Positive";
            } 
           
            else
            {
                lbl2.Text = "Available Rooms Negative";

            }
:code:

This post has been edited by modi123_1: 11 July 2019 - 12:59 PM
Reason for edit:: In the future, please use the [code] tag button in the editor.


Is This A Good Question/Topic? 0
  • +

Replies To: Online Hotel Reservation system

#2 DarenR   User is offline

  • D.I.C Lover

Reputation: 634
  • View blog
  • Posts: 4,218
  • Joined: 12-January 10

Re: Online Hotel Reservation system

Posted 11 July 2019 - 10:56 AM

ok what is your question
Was This Post Helpful? 0
  • +
  • -

#3 aimaishanu   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-July 19

Re: Online Hotel Reservation system

Posted 11 July 2019 - 12:57 PM

my question is i want to check if there are available rooms. i have a column named roomstatus. I used 1 for active and 0 vacant. How can i do it?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15359
  • View blog
  • Posts: 61,588
  • Joined: 12-June 08

Re: Online Hotel Reservation system

Posted 11 July 2019 - 01:01 PM

First is your query getting *ALL* the rooms not with an active status?

Are you trying to get one specific room?

Would it make more sense to check for 'room status = 0'?

Second - you can use an adapter to fill a dataset with results, or a sql command to 'execute scalar' for one specific value.

Old VB.NET code on that.

https://www.dreaminc...-adapter-setup/
Was This Post Helpful? 0
  • +
  • -

#5 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2999
  • View blog
  • Posts: 11,546
  • Joined: 03-December 12

Re: Online Hotel Reservation system

Posted 12 July 2019 - 10:04 AM

View Postaimaishanu, on 11 July 2019 - 02:57 PM, said:

my question is i want to check if there are available rooms. i have a column named roomstatus. I used 1 for active and 0 vacant. How can i do it?

If you want to look for available rooms, why are you asking for status only?

select roomstatus from Room where roomstatus != 1


As modi said, WHERE roomstatus = 0 would give you all vacant rooms, but wouldn't you also want to know what rooms are actually available?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1