Ajax Event Calendar Support Product Page

Using Unigue value and query with joins to generate a personnel calendar

Asked 27 Jan 2011 13:27:23
1
has this question
27 Jan 2011 13:27:23 andrew grant posted:
win 7, dreamweaver cs4, ajax event calendar version 1.0.2 , IE 7 + Chrome,No live sample.ASP Classic, .NET, Access DB 2003.

Aim: I want to use the calendar so individual empolyees can see their workload out putted on the calendar.

Employess have a unigue ID in the access Db. The records are held in 3 tables all linked

1) tbl.personnel (with Unigue ID 'personID')
2) tbl_timesheets
3) tbl_lu_timesheets
These are used in a Join.

I already use the system so the Db and relationships are fine as are the queries .

I have a seperate page, with logon, for each person, authenicated via their 'personI[B)][B)]D' value login value.

I want to use this Join in the calendar_get_events.asp genertaed by the extention ..

My SQL Query
-----------------
SELECT personnel.*, timesheet.*, lu_timesheet.*
FROM (personnel INNER JOIN timesheet ON personnel.PersonID = timesheet.PersonID) INNER JOIN lu_timesheet ON timesheet.timesheet_lookupID = lu_timesheet.timesheet_lookupID;
Where personnel.PersonID = value from request query string here
----------------
The code on the calendar is ..


Set dmxEventsRs_cmd = Server.CreateObject ("ADODB.Command")
  dmxEventsRs_cmd.ActiveConnection = MM_fusion_STRING
  dmxEventsRs_cmd.CommandText = [i]"SELECT [title], [start], [stop]  FROM [timesheet] WHERE DATEDIFF('s',#01-01-1970#,[start]) <= ? AND (DATEDIFF('s',#01-01-1970#,[stop]) >= ? OR ([stop] IS NULL AND DATEDIFF('s',#01-01-1970#,[start]) >= ?))"[/i]
  dmxEventsRs_cmd.Parameters.Append dmxEventsRs_cmd.CreateParameter("@stop", 3, 1, , request_Stop)
  dmxEventsRs_cmd.Parameters.Append dmxEventsRs_cmd.CreateParameter("@start", 3, 1, , request_Start)
  dmxEventsRs_cmd.Parameters.Append dmxEventsRs_cmd.CreateParameter("@start2", 3, 1, , request_Start)
  dmxEventsRs_cmd.Prepared = true  
  dim rsJson, cb 
  set rsJson = QueryToJSON(dmxEventsRs_cmd, "")
  cb = Request.QueryString("callback")


Can you help

Replies

Replied 27 Jan 2011 15:10:47
27 Jan 2011 15:10:47 Miroslav Zografski replied:
Hello Andrew,

you can stitch those two queries together


SELECT personnel.*, timesheet.*, lu_timesheet.*
FROM (personnel INNER JOIN timesheet ON personnel.PersonID = timesheet.PersonID) INNER JOIN lu_timesheet ON timesheet.timesheet_lookupID = lu_timesheet.timesheet_lookupID WHERE personnel.PersonID = '
?' AND DATEDIFF('s',#01-01-1970#,[start]) <= ? AND (DATEDIFF('s',#01-01-1970#,[stop]) >= ? OR ([stop] IS NULL AND DATEDIFF('s',#01-01-1970#,[start]) >= ?


... but that is not tested and I advise you to make a back up of the Access before testing it yourself.
Also you will need to add the value from request query string as dmxEventsRs_cmd.Parameters.Append dmxEventsRs_cmd.CreateParameter() - check for that in any ASP reference guides.

Regards,

Reply to this topic