I am currently making a booking system for a hotel. My select query for available rooms works perfect when a rooms been booked only once. The statement is meant to show a room in a table when it is available and to show nothing if they're not available on the selected date. This doesn't work when a room is booked twice even when the selected date is different to when it was booked. It still shows the room even though it is unavailable.
Here is the query
SELECT DISTINCT
Room_Type.Room_typeID, Room_Type.Room_tariffID, Room_Type.Description
FROM
Room_Type
INNER JOIN
Booking ON Booking.Room_typeID = Room_Type.Room_typeID
WHERE
(Room_Type.Description = @Param1)
AND (Booking.Check_in_date <> @Param2)
Booking table
BookingID
CustomerID
Room_TypeID
Check_In_Date
Check_Out_Date
Num_Of_Guests
Room_type table
Room_TypeID
Room_TarriffID
Description
Code to call the query
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim SearchDB As New HotelTableAdapters.Room_TypeTableAdapter
Dim GetAvailaibility As Hotel.Room_TypeDataTable = SearchDB.GetDataByRoomAvailability(DDRoomType.Text, Calendar1.SelectedDate.ToShortDateString())
If GetAvailability.Rows.Count > 0 then
Dim RoomDescription As String = GetAvailaibility(0)("Description")
Dim Price As Integer = GetAvailaibility(0)("Room_TariffID")
Dim Roomtypeid As Integer = GetAvailaibility(0)("Room_TypeID")
Dim DateCheckin As Date = Calendar1.SelectedDate.ToShortDateString
IDlabel.Text = Roomtypeid
roomlabel.Text = RoomDescription
pricelabel.Text = Price
Session("Room_TypeID") = Roomtypeid
Session("Description") = RoomDescription
Session("Check_in_date") = DateCheckin
Session("Room_TarriffID") = Price
Else Label1.text = ("Room Unavailable")