%
Session("CurrentPage") = "AdminLinks"
If Session( "LoginID" ) < "1" Then
Response.Redirect( "adminlogin.asp" )
End If
%>
<%
Dim dbConn, Rs, strX
'Open up a database connection and set up the recordset
Set dbConn = Session("dbConn")
Set Rs = Server.CreateObject("adodb.recordset")
Rs.Cursortype=adOpenDynamic
Rs.LockType=adLockOptimistic
If rqs("do") = "add" or rqs("do") = "edit" Then
'Get the details from the user via a form
rsw( strHeader )
IF rqs("do") = "add" Then
strX = "SELECT * FROM Links WHERE [ID] < 0"
Else
strX = "SELECT * FROM Links WHERE [ID] = " & rqs("id")
End If
Rs.Open strX, dbConn
rsw("")
%>
<%
Rs.Close
ElseIf rqs("do") = "delete" Then
'delete the record'
on error resume next
If rqs("id") <> "" Then
cSQL = "DELETE * FROM Links WHERE ID = " & rqs("id")
dbConn.Execute(cSQL)
End If
If Err.Number = 0 Then
response.redirect( Session("CurrentPage") & ".asp" )
Else
rsw( strHeader )
WriteDBError "CANT DELETE THE RECORD",err.Description,cSQL
End If
on error goto 0
ElseIf rqs("do") = "deletepic" Then
'delete the record'
on error resume next
If rqs("id") <> "" Then
cSQL = "UPDATE Links SET PicLink = NULL WHERE ID = " & rqs("id")
dbConn.Execute(cSQL)
End If
If Err.Number = 0 Then
response.redirect( Session("CurrentPage") & ".asp" )
Else
rsw( strHeader )
WriteDBError "CANT DELETE THE PICTURE",err.Description,cSQL
End If
on error goto 0
ElseIf rqs("do") = "update" Then
'Submit the details back to the database
IF rqf("id") < "1" Then
cSQL = "INSERT INTO Links( Organisation, Link, Priority ) " & _
"VALUES( " & _
strSQLField(rqf("organisation"),"c") & ", " & _
strSQLField(rqf("link"),"c") & " ," & _
strSQLField(rqf("priority"),"n") & " )"
Else
cSQL = "UPDATE Links SET " & _
"[Organisation] = " & strSQLField(rqf("organisation"),"c") & ", " & _
"[Link] = " & strSQLField(rqf("link"),"c") & ", " & _
"[Priority] = " & strSQLField(rqf("priority"),"n") & " " & _
"WHERE ID = " & rqf( "id" )
End If
on error resume next
dbConn.Execute(cSQL)
If Err.Number = 0 Then
response.redirect( Session("CurrentPage") & ".asp?d=" & now() )
Else
rsw( strHeader )
WriteDBError "CANT UPDATE THE RECORD",err.Description,cSQL
End If
on error goto 0
Else
rsw( vbCrLF & vbCrLF )
rsw( "