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(vacancySearchSQL, gblConnection)
        Dim vacancySearchDataSet As New DataSet
        Try
            vacancySearchDataAdapter.Fill(vacancySearchDataSet, "tblReservations")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Try
            dgVacancyResults.SetDataBinding(vacancySearchDataSet, "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.
isrxlAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

amit_gCommented:
Try this ...

        Dim vacancySearchSQL As String = "SELECT * FROM ProMARS.tblReservations WHERE (resArrivalDate > " & "#" & dtpSrchStartDate.Text & "#" & " and resArrivalDate > " & "#" & dtpSrchEndDate.Text & "#" & ")" & " or " & "(resDepartureDate < " & "#" & dtpSrchStartDate.Text & "#" & " and resDepartureDate < " & "#" & dtpSrchEndDate.Text & "#" & ")"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
isrxlAuthor Commented:
Dear amit g, thank you so much, you saved the day for me.
0
amit_gCommented:
Glad to be of help :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.