If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > VB.NET SQL Problem - Help please!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-08-10, 12:56
Keep_Coding Keep_Coding is offline
Registered User
 
Join Date: Jun 2010
Posts: 2
Question VB.NET SQL Problem - Help please!

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 roomID
FROM Room INNER JOIN Booking ON Room.RoomID = Booking.RoomID
WHERE 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.
Reply With Quote
  #2 (permalink)  
Old 06-08-10, 13:52
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
That is definitely not a valid MySQL Syntax (actually the & thing is not valid in any SQL I know)

This looks like SQL Server, you should post the question there.

And post the real SQL Statement not your VB code (print the real SQL statement and most probably you'll se the error yourself)
Reply With Quote
  #3 (permalink)  
Old 06-08-10, 13:55
Keep_Coding Keep_Coding is offline
Registered User
 
Join Date: Jun 2010
Posts: 2
I dont understand what you mean? I have not posted any visual basic coding at all.. This is the SQL command that I am trying to create an place in VB.NET
Reply With Quote
  #4 (permalink)  
Old 06-08-10, 14:46
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
Take a look at LIMIT to specify that you only want a single row returned. Something like: LIMIT 0,1. Also, I would move "AND Booking.[Date of Departure] < Now()" into the ON clause just for clarity sake.
Dave
Reply With Quote
  #5 (permalink)  
Old 06-08-10, 15:25
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
Quote:
Originally Posted by Keep_Coding View Post
I dont understand what you mean? I have not posted any visual basic coding at all
Sure you have: LIKE '" & Room_TypeTextbox.Text & "'" is not valid SQL, it's VB (or some other programming language)

and AND Booking.[Date of Departure] < Now() is not valid syntax for MySQL, it's the wrong forum.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On