VB.NET SQL Help.. Urgent!

Discussion in 'Visual Basic ( VB )' started by Keep_Coding, Jun 9, 2010.

  1. Keep_Coding

    Keep_Coding New Member

    Joined:
    Jun 9, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I have created a hotel booking system programme. However, I am puzzled as to how when the booking button is clicked it can search a database and find the best suited room (RoomType) and make sure that it is available (Date of Departure < system.date).

    This data is held in two tables (Access):


    Booking:BookingID (Primary Key)CustomerID (Foreign Key, Table:Customer)Date of Arrival (Date)Date of Departure (Date)RoomID (Foreign Key,Table:Room)



    Room:RoomID (Primary Key)RoomType (Text)RoomPrice (Currency)Floor (Number)



    This has all got to be done within a single button click. Any ideas as to how I can place this into my vb code?

    I have a rough query for picking a room that is best suited:

    Code:


    SELECT top 1 roomIDFROM Room INNER JOIN Booking ON Room.RoomID = Booking.RoomIDWHERE Room.[Room Type] LIKE '" & Room_TypeTextbox.Text & "'"AND Booking.[Date of Departure] < Now()



    I have been trying for a while to get it to select a single matching record as there is a high chance that this query will return multiple records but im unsure on how to deal with that.

    Any help would be hugely appreciated.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice