Indsætte MM_username
Jeg skal sætte en kalender ind på en hjemmeside, men de events som sættes ind skal kun dem som sætter dem ind kunne se.Jeg har lavet et recordset bruger som skal flettets ind i det eksisterende, jeg syntes at jeg har prøvet alt, men kan ikke få det til at fungere. Jeg er i tvivl om det kan fungere.
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../Connections/db.asp" -->
<%
Dim bruger__MMColParam
bruger__MMColParam = "1"
If (Session("MM_username") <> "") Then
bruger__MMColParam = Session("MM_username")
End If
%>
<%
Dim bruger
Dim bruger_cmd
Dim bruger_numRows
Set bruger_cmd = Server.CreateObject ("ADODB.Command")
bruger_cmd.ActiveConnection = MM_db_STRING
bruger_cmd.CommandText = "SELECT * FROM kalender WHERE brugernavn = ?"
bruger_cmd.Prepared = true
bruger_cmd.Parameters.Append bruger_cmd.CreateParameter("param1", 200, 1, 255, bruger__MMColParam) ' adVarChar
Set bruger = bruger_cmd.Execute
bruger_numRows = 0
%>
<!--#include file="../Scriptlibrary/JSON_latest.asp"-->
<!--#include file="../Scriptlibrary/JSON_UTIL_latest.asp"-->
<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
'handler="db"
'table="[kalender]"
'title="[event_title]"
'start="[start]"
'stop="[stop]"
'description="[description]"
'type="[type]"
'link=""
'event_id="[event_id]"
'db_type="access"
Dim dmxEventsRs
Dim dmxEventsRs_cmd
Dim dmxEventsRs_numRows
Dim request_Start, request_Stop
request_Start = Request.QueryString("start")
request_Stop = Request.QueryString("stop")
IF isEmpty(request_Start) THEN
Response.Status = "400 Bad Request"
Response.Write "Start is required"
Response.End
ELSEIF NOT isNumeric(request_Start) THEN
Response.Status = "400 Bad Request"
Response.Write "Start should be a number"
Response.End
ELSEIF isEmpty(request_Stop) THEN
Response.Status = "400 Bad Request"
Response.Write "Stop is required"
Response.End
ELSEIF NOT isNumeric(request_Stop) THEN
Response.Status = "400 Bad Request"
Response.Write "Stop should be a number"
Response.End
ELSE
Set dmxEventsRs_cmd = Server.CreateObject ("ADODB.Command")
dmxEventsRs_cmd.ActiveConnection = MM_db_STRING
dmxEventsRs_cmd.CommandText = "SELECT [event_title] AS title, [start], [stop] , [description], [type], [event_id] FROM [kalender] 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]) >= ?))"
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")
If cb <> "" Then
Response.Write cb & "("& rsJson.jsString &");"
Else
Response.Write rsJson.jsString
End If
END IF
%>
<%
bruger.Close()
Set bruger = Nothing
%>