isrxl
asked on
VB.net, Access & date/time picker: writing sql query to find units available for reservation between 2 given dates
Greetings:
As mentioned, I'm working with VB.NET Windows Form and an Access DataBase. A table in the database stores room numbers and the reservation dates for these rooms (resArrivalDate & resDepartureDate) among other things.
I have, in the Form, 2 date/time picker controlls used to pick a start and an end dates to search for availability of the rooms between the two dates selected. The results should be displayed on a datagrid controll but for some reason my query doesn't seem to work; it returns all of the rooms regardless of their availability.
Here's the code used in the search function:
Dim vacancySearchSQL As String = "SELECT * FROM ProMARS.tblReservations WHERE resDepartureDate < " & dtpSrchStartDate.Text & " OR resArrivalDate > " & dtpSrchEndDate.Text
Dim vacancySearchDataAdapter As New OleDbDataAdapter(vacancySe archSQL, gblConnection)
Dim vacancySearchDataSet As New DataSet
Try
vacancySearchDataAdapter.F ill(vacanc ySearchDat aSet, "tblReservations")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Try
dgVacancyResults.SetDataBi nding(vaca ncySearchD ataSet, "tblReservations")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Sorry if the question seems silly, but I haven't had much experience dealing with databases and time. Your help or pointing me to a source with good information on this would be greatly appreciated. Thank you.
As mentioned, I'm working with VB.NET Windows Form and an Access DataBase. A table in the database stores room numbers and the reservation dates for these rooms (resArrivalDate & resDepartureDate) among other things.
I have, in the Form, 2 date/time picker controlls used to pick a start and an end dates to search for availability of the rooms between the two dates selected. The results should be displayed on a datagrid controll but for some reason my query doesn't seem to work; it returns all of the rooms regardless of their availability.
Here's the code used in the search function:
Dim vacancySearchSQL As String = "SELECT * FROM ProMARS.tblReservations WHERE resDepartureDate < " & dtpSrchStartDate.Text & " OR resArrivalDate > " & dtpSrchEndDate.Text
Dim vacancySearchDataAdapter As New OleDbDataAdapter(vacancySe
Dim vacancySearchDataSet As New DataSet
Try
vacancySearchDataAdapter.F
Catch ex As Exception
MsgBox(ex.Message)
End Try
Try
dgVacancyResults.SetDataBi
Catch ex As Exception
MsgBox(ex.Message)
End Try
Sorry if the question seems silly, but I haven't had much experience dealing with databases and time. Your help or pointing me to a source with good information on this would be greatly appreciated. Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad to be of help :)
ASKER