Server Side Script Examples

Included below are some examples of hand-coded server-side code created.

*** ASP / ADSI LDAP CONNECTION – RETRIEVES DATA VIA NOVELL NDSI

<%

‘ Create ADO Connection object
Set ADOconnObj = CreateObject(“ADODB.Connection”)
bstrADOQueryString = “<LDAP://209.101.173.159:389/o=whs>;(u0026amp;(objectClass=organizationalPerson)(cn=WallsJ)(o=whs));adspath,cn;subtree”

ADOconnObj.Provider = “ADSDSOObject”
ADOconnObj.Open “ADs Provider”
response.write bstrADOQueryString u0026amp; ” query<br>”
Set RSObj = ADOconnObj.Execute(bstrADOQueryString)
Response.Write RSObj.RecordCount u0026amp; ” records found:” u0026amp; “<br>”

Response.Write objContainer.GetInfo u0026amp; “Get Info”
Response.Write objContainer.PropertyCount u0026amp; “Property Count”
For i = 1 to objContainer.PropertyCount
Set vProp = objContainer.Next
Response.Write(“<LI>” u0026amp; vProp.Name u0026amp; “<br>”)
Next
%>

*** ASP – DATA RETRIEVAL/DISPLAY – DYNAMIC PRESENTATION LAYER CODE
*** STORED PROCEDURES – EXECUTE ADO CONNECTION + RESULT SET POPULATION
<%
set GetAvailConn = Server.CreateObject(“ADODB.Command”)
GetAvailConn.ActiveConnection = MM_SGC_STRING
GetAvailConn.CommandText = “dbo.Get_PicksAvailTodayTest”
GetAvailConn.CommandType = 4
GetAvailConn.CommandTimeout = 0
GetAvailConn.Prepared = true
set GetAvail = GetAvailConn.Execute
GetAvail_numRows = 0

%>
<%

set GetPicks = Server.CreateObject(“ADODB.Command”)
GetPicks.ActiveConnection = MM_SGC_STRING
GetPicks.CommandText = “dbo.Get_DailyPicksDisplay”
GetPicks.CommandType = 4
GetPicks.CommandTimeout = 0
GetPicks.Prepared = true
set DisplayPicks = GetPicks.Execute
DisplayPicks_numRows = 0

%>

*** ASP – TABLE CURSOR – SEQUENTIALLY WRITTEN WHILE RECORDSET VALUE IS NOT EMPTY
<%
Dim bTableOpen : bTableOpen = False
Dim sLastID : sLastID = “”
DisplayPicks.MoveFirst
Do Until DisplayPicks.EOF
If DisplayPicks (“UserID”) <> sLastID Then
If bTableOpen Then %>
</TABLE>
<% bTableOpen = False
End If %>
<!– TABLE –>
<H3><font color=”#3a297d”><%= DisplayPicks.Fields.Item(“FirstName”).Value %>’su0026amp;nbsp;Pick’s </font></H3>
<% bTableOpen = True
sLastID = DisplayPicks (“UserID”)
End If
‘ sLastID = DisplayPicks (“UserID”)
‘write your row of data here using your recordset
%>
<%
‘ While ((Repeat1__numRows <> 0) AND (NOT DisplayPicks.EOF))
%>

<%
DisplayPicks.MoveNext
Loop
%>

*** ASP – DISPLAYS GRAPHIC TYPE BASED ON RECORDSET VALUE
<%
IF DisplayPicks.Fields.Item(“Pick_Sport”).value = “NFL” THEN
Response.Write “<img name=’NFL’ border=’0′ src=’/images/footballicon.jpg’>”
ELSE
IF DisplayPicks.Fields.Item(“Pick_Sport”).value = “CFB” THEN
Response.Write “<img name=’NFL’ border=’0′ src=’/images/footballicon.jpg’>”
ELSE
IF DisplayPicks.Fields.Item(“Pick_Sport”).value = “NBA” THEN
Response.Write “<img name=’NFL’ border=’0′ src=’/images/basketballicon.jpg’>”
ELSE
IF DisplayPicks.Fields.Item(“Pick_Sport”).value = “CBB” THEN
Response.Write “<img name=’NFL’ border=’0′ src=’/images/basketballicon.jpg’>”
ELSE
IF DisplayPicks.Fields.Item(“Pick_Sport”).value = “MLB” THEN
Response.Write “<img name=’NFL’ border=’0′ src=’/images/baseballicon.jpg’>”
END IF
END IF
END IF
END IF
End IF
%>
*** ASP/VBSCRIPT FUNCTION – WRITES SEQUENTIAL DATE INTO SELECT FORM
<%
Function AddWorkingDays(nDaystoAdd)
‘Adds working days based on a five day week
Dim dtEndDate, dtStartDate
Dim iLoop
dtStartDate = FormatDateTime((Now-0),vbShortDate)
‘First add whole weeks
dtEndDate=FormatDateTime((Now-7),vbShortDate)
dtEndDate=DateAdd(“ww”,Int(nDaysToAdd/5),dtStartDate)

‘Add any odd days
For iLoop = 1 To (nDaysToAdd Mod 5)
dtEndDate=DateAdd(“d”,1,dtEndDate)
‘ removed weekend code from here
Next
AddWorkingDays = FormatDateTime(dtEndDate,vbShortDate)
End Function

%>

<%
‘ removed option selected code from here
For X = 0 To 6
strDate = addWorkingDays(X)
Response.Write “<OPTION value=” u0026amp; strDate u0026amp; “>” u0026amp; strDate u0026amp; “</option>”
Next
%>