Click here to Skip to main content
15,894,410 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm making a Hotel Booking System. I have 15 buttons representing each room. Once the date in has been selected, if a room has been booked, then I need the button with the room number on it to turn red and cannot be selected. However, I also need the button to be red with the time in-between the date in and date out.

So basically, I need to search the access database with the date that has been selected, which turns the button red with the same number as the room number in the database and doesn't allow a booking between the Date In and Date Out.

I have no idea where to start since I am pretty new to programming.

What I have tried:

I have tried this but this is nowhere near what I need.
Dim BookingFound As String = False
      MyConn = New OleDbConnection

      MyConn.ConnectionString = connString
      MyConn.Open()

      str1 = ("SELECT * FROM [BookingInformation] WHERE [Date In] = #" & dtpDateIn.Value.Date & "#")

      Dim cmd1 As OleDbCommand = New OleDbCommand(str1, MyConn)
      dr = cmd1.ExecuteReader

      While dr.Read()
          BookingFound = True

          strDateOut = dr("Date Out").ToString
          strDateIn = dr("Date In").ToString
          strRoomNumber = dr("Room Number").ToString

          If BookingFound = True Then

          End If


      End While
      MyConn.Close()
  End Sub
Posted
Updated 10-Sep-17 8:00am

Here is an example, both VB6 and VB.NET code available: Hotel Reservation System[^]

And another one, using VB.NET and ACCESS: Simple Hotel Management System Using VB.Net | Free source code, tutorials and articles[^]
 
Share this answer
 
v2
Quote:
if a room has been booked, then I need the button with the room number on it to turn red and cannot be selected. However, I also need the button to be red with the time in-between the date in and date out.

Looks like your statement is missing something big.
Say that on Saturday, rooms 1 to 10 are booked, and on Sunday, rooms 10 to 15 are booked.
With your statement, you can't book a room for those 2 days because no room is available over this period.
The solution you are missing is the feature to move a booking on Sunday to another room, which free a room for those 2 days.
For more than 2 nights, you may have to move more bookings in order to free a room over the period.
----
VB
str1 = ("SELECT * FROM [BookingInformation] WHERE [Date In] = #" & dtpDateIn.Value.Date & "#")

Not a solution to your question, but another problem you have.
Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability named "SQL injection", it is dangerous for your database and error prone.
A single quote in a name and your program crash. If a user input a name like "Brian O'Conner" can crash your app, it is an SQL injection vulnerability, and the crash is the least of the problems, a malicious user input and it is promoted to SQL commands with all credentials.
SQL injection - Wikipedia[^]
SQL Injection[^]
SQL Injection Attacks by Example[^]
PHP: SQL Injection - Manual[^]
SQL Injection Prevention Cheat Sheet - OWASP[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900