SQL query in VS help required

  • Thread starter Thread starter pw2002uk
  • Start date Start date
P

pw2002uk

Guest
Good day everyone - I hope this is a simple question! - I have the following query written VB.

I have two tables, one called person_data_table that holds all the names (and their teams), and one called date_table that holds all the data. I pass in a team name from the client at the front end and I want to find the following

All the people that are on the team, but NOT anyone that is on vacation on that day. (date_table.allocated). I can find all the team members, and I can find all the people on vacation on that day, but I can't seem to work out a way of finding the team members but excluding the vacation people. Hope that makes sense, please leave a message if not, and I will try to explain further.

I tried this where clause below and that returned only the people on holiday that were on vacation - I need the exact opposite, I want to exclude them, and see everyone else

Where Person_data_Table.MK = Date_Table.FK And Date_Table.Allocated = "Vacation" And Date_Table.Date = Today And Person_data_Table.Team Like data_type_requested_variable + "*"

The code below does not return any records at all.

Any help gratefully received, please keep it in VB, the C# syntax does not seem to work well for me.


regards

Peter

<System.Web.Services.WebMethod()> Public Shared Function Save_Data(ByVal data_type_requested_variable As String) As String


Using db As New MaxDataContext


'Finds on vacation by selected team
'Where Person_data_table.MK = Date_Table.FK And Date_Table.Allocated = "Vacation" And Date_Table.Date = Today And Person_data_table.Team Like data_type_requested_variable + "*"



Dim selected_type = From Person_data_Table In db.Person_data_tables, Date_Table In db.Date_Tables
Where Person_data_Table.MK = Date_Table.FK And Date_Table.Allocated <> "Vacation" And (Date_Table.Date = Today And Person_data_Table.Team Like data_type_requested_variable + "*")
Select Person_data_Table.First_Name, Person_data_Table.Type, Person_data_Table.Fri_Avail, Person_data_Table.Sat_Avail


Dim Hidden_results_grid As New GridView
Hidden_results_grid.DataSource = selected_type
Hidden_results_grid.DataBind()

Continue reading...
 
Back
Top