Thread: Error messages
View Single Post
  #7 (permalink)  
Old June 5th, 2005, 12:07 PM
ldoodle ldoodle is offline
Authorized User
 
Join Date: Jun 2005
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is the code I have for the default.asp (first page);

Code:
<%
    Dim objConn, rsEA, strSQL, strUserName, strUserStyle, strDefaultData, strUserInfo, strURL

    strUserName = Request.ServerVariables("LOGON_USER")
    strDefaultStyle = "blue"

    Set objConn = Server.CreateObject("ADODB.Connection")
        objConn.Open "DBQ=" & Server.MapPath("/database/ea.mdb") & ";DRIVER={Microsoft Access Driver (*.mdb)};"

    Set rsEA = Server.CreateObject("ADODB.Recordset")

    strSQL = "SELECT tblStyleSheet.UserName, tblStyleSheet.UserStyle FROM tblStyleSheet;"

        rsEA.CursorType = 2
        rsEA.LockType = 3
        rsEA.Open strSQL, objConn

***************************
        objConn.Execute "INSERT INTO [tblStyleSheet]" & " ([UserName], [UserStyle])" & " VALUES('" & strUserName & "','" & "blue" & "');"
***************************

    set strUserData = Server.CreateObject("ADSystemInfo")
    set strUserInfo = getObject ("LDAP://" & strUserData.Username)
    strURL = "/html/error.asp"
        For Each Group in strUserInfo.Groups
            If Group.cn = "AYL Administrators" Then
                strURL = "/admins/index.asp"
            End If
            If Group.cn = "AYL Support Staff" or Group.cn = "AYL Teachers" Then
                strURL = "/staff/index.asp"
            End If
//            If Group.cn = "AYL Key Stage 3" or Group.cn = "AYL  Key Stage 4" or Group.cn = "AYL  Key Stage 5" Then
//                strURL = "/students/index.asp"
//            End If
        Next
%>
As you can see, the code inside the *'s is the initial insertion of the record, but there's nothing there to check if it already exists.