0

I have an SQL select statement that I cannot quite get working.

Dim SelectStr As String = "SELECT * FROM Appointments WHERE Doctor = '" & ComboBox1.Text & "' AND AptDate = #" & DateTimePicker1.Text & "#"

This works perfect ... however I have 2 more WHERE possibilities ... I would like to include all of the above Appointments where PatientName <> "" OR AddName <> "". Basically I want to retrieve patients in the main appointment slot and in the additional appointment slot (just not the rest of the empty timeslots).

The following line of code I tried that did not work only supplied me with those appointments where PatientName <> "" and totally ignored the AddName <> ""

Dim schedphoneSelectStr As String = "SELECT * FROM Appointments WHERE Doctor = '" & ComboBox1.Text & "' AND AptDate = #" & DateTimePicker1.Text & "# AND PatientName <> "" OR AddName <> "" "

Any help would be appreciated.

3
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by poojavb
0

This could be tricky depending on what you really want. If you are trying to group patientname and addname then place a parenthesis around that gorup. The parenthesis turns that group into either a true or false. Without the parethesis, each is its own true or false in the overall statement. Not sure if I am making sense... Dont you also want to change the OR to an AND Try this ... AND (PatientName <> "" AND AddName <> "" )

0

Add paranthesis and use the OR instead of AND and see if it works...if u r grouping it means it has to fulfill the condition...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.