%@ LCID = 3081 %>
<%
Response.expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
Response.addHeader "cache-control", "no-cache"
Response.addHeader "cache-control", "no-store"
Response.CacheControl = "no-cache"
%>
<%
ewCurSec = 0 ' Initialise
' User levels
Const ewAllowAdd = 1
Const ewAllowDelete = 2
Const ewAllowEdit = 4
Const ewAllowView = 8
Const ewAllowList = 8
Const ewAllowReport = 8
Const ewAllowSearch = 8
Const ewAllowAdmin = 16
%>
<%
' Initialize common variables
x_SITE_HEADING = Null: ox_SITE_HEADING = Null
x_SITE_URL = Null: ox_SITE_URL = Null
x_COMMENTS = Null: ox_COMMENTS = Null
x_DFRECNUM = Null: ox_DFRECNUM = Null
%>
<%
Response.Buffer = True
' Load Key Parameters
sKey = "": bSingleDelete = True
x_DFRECNUM = Request.QueryString("DFRECNUM")
If x_DFRECNUM <> "" Then
If sKey <> "" Then sKey = sKey & ","
sKey = sKey & x_DFRECNUM
Else
bSingleDelete = False
End If
If Not bSingleDelete Then
sKey = Request.Form("key_d")
End If
If sKey = "" Or IsNull(sKey) Then Response.Redirect "SITELINKlist.asp"
arRecKey = Split(sKey&"", ",")
i = 0
Do While i <= UBound(arRecKey)
sDbWhere = sDbWhere & "("
' Remove spaces
sRecKey = Trim(arRecKey(i+0))
' Build the SQL
sDbWhere = sDbWhere & "[DFRECNUM]=" & AdjustSql(sRecKey) & " AND "
If Right(sDbWhere, 5) = " AND " Then sDbWhere = Left(sDbWhere, Len(sDbWhere)-5) & ") OR "
i = i + 1
Loop
If Right(sDbWhere, 4) = " OR " Then sDbWhere = Left(sDbWhere, Len(sDbWhere)-4)
' Get action
sAction = Request.Form("a_delete")
If sAction = "" Or IsNull(sAction) Then
sAction = "I" ' Display record
End If
' Open connection to the database
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str
Select Case sAction
Case "I": ' Display
If LoadRecordCount(sDbWhere) <= 0 Then
conn.Close ' Close Connection
Set conn = Nothing
Response.Clear
Response.Redirect "SITELINKlist.asp"
End If
Case "D": ' Delete
If DeleteData(sDbWhere) Then
Session("ewmsg") = "Delete Successful"
conn.Close ' Close Connection
Set conn = Nothing
Response.Clear
Response.Redirect "SITELINKlist.asp"
End If
End Select
%>
Delete from TABLE: SITELINK
Back to List
<%
conn.Close ' Close Connection
Set conn = Nothing
%>
<%
'-------------------------------------------------------------------------------
' Function LoadData
' - Load Data based on Key Value
' - Variables setup: field variables
Function LoadData()
Dim sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy
sSql = "SELECT * FROM [SITELINK]"
sWhere = ""
sGroupBy = ""
sHaving = ""
sOrderBy = ""
If sWhere <> "" Then sWhere = sWhere & " AND "
sWhere = sWhere & "([DFRECNUM] = " & AdjustSql(x_DFRECNUM) & ")"
sSql = sSql & " WHERE " & sWhere
If sGroupBy <> "" Then
sSql = sSql & " GROUP BY " & sGroupBy
End If
If sHaving <> "" Then
sSql = sSql & " HAVING " & sHaving
End If
If sOrderBy <> "" Then
sSql = sSql & " ORDER BY " & sOrderBy
End If
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sSql, conn
If rs.Eof Then
LoadData = False
Else
LoadData = True
rs.MoveFirst
' Get the field contents
x_SITE_HEADING = rs("SITE_HEADING")
x_SITE_URL = rs("SITE_URL")
x_COMMENTS = rs("COMMENTS")
x_DFRECNUM = rs("DFRECNUM")
End If
rs.Close
Set rs = Nothing
End Function
%>
<%
'-------------------------------------------------------------------------------
' Function LoadRecordCount
' - Load Record Count based on input sql criteria sqlKey
Function LoadRecordCount(sqlKey)
Dim sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy
sSql = "SELECT * FROM [SITELINK]"
sSql = sSql & " WHERE " & sqlKey
sGroupBy = ""
sHaving = ""
sOrderBy = ""
If sGroupBy <> "" Then
sSql = sSql & " GROUP BY " & sGroupBy
End If
If sHaving <> "" Then
sSql = sSql & " HAVING " & sHaving
End If
If sOrderBy <> "" Then
sSql = sSql & " ORDER BY " & sOrderBy
End If
Set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3
rs.Open sSql, conn, 1, 2
LoadRecordCount = rs.RecordCount
rs.Close
Set rs = Nothing
End Function
%>
<%
'-------------------------------------------------------------------------------
' Function DeleteData
' - Delete Records based on input sql criteria sqlKey
Function DeleteData(sqlKey)
Dim sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy
sSql = "SELECT * FROM [SITELINK]"
sSql = sSql & " WHERE " & sqlKey
sGroupBy = ""
sHaving = ""
sOrderBy = ""
If sGroupBy <> "" Then
sSql = sSql & " GROUP BY " & sGroupBy
End If
If sHaving <> "" Then
sSql = sSql & " HAVING " & sHaving
End If
If sOrderBy <> "" Then
sSql = sSql & " ORDER BY " & sOrderBy
End If
Set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3
rs.Open sSql, conn, 1, 2
Do While Not rs.Eof
rs.Delete
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
DeleteData = True
End Function
%>