Forum Moderators: open
this is the page....
<%Option Explicit%>
<!--#include virtual="/IntranetDesignProject/Connections/dsnIKH.asp" -->
<%
'dimension variables
Dim userFirstName, userLastName, userJobTitle, userInternalPhone, userInternalEmail, userPassword, userDept, levelID, rsAddUser, aLevelID, i, strSQL, userID, adoCon, isUser, userHomeAddress, userHomePhone, userHomeEmail
'function to remove single quotes from input
Function stripQuotes(strQuotes)
Dim strOutput
strOutput = Replace(strQuotes, "'","''")
stripQuotes = strOutput
End Function
'which form are we updating user or admin
isUser = false
If Request.Form("formUser") > "" Then
isUser = true
End If
'put the values from our form into variables, using the function stripQuotes to remove quotes
'these are common to both forms
userFirstName = stripQuotes(Request.Form("userFirstName"))
userLastName = stripQuotes(Request.Form("userLastName"))
userJobTitle = stripQuotes(Request.Form("userJobTitle"))
userInternalPhone = stripQuotes(Request.Form("userInternalPhone"))
userInternalEmail = stripQuotes(Request.Form("userInternalEmail"))
userID = Request.Form("userID")
If isUser = true Then
'form fields for user form
userHomeAddress = stripQuotes(Request.Form("userHomeAddress"))
userHomePhone = stripQuotes(Request.Form("userHomePhone"))
userHomeEmail = stripQuotes(Request.Form("userHomeEmail"))
strSQL = "UPDATE tblUsers SET userFirstName = '" & userFirstName & "', userLastName = '" & userLastName & "', userJobTitle = '" & userJobTitle & "', userInternalPhone = '" & userInternalPhone & "', userInternalEmail = '" & userInternalEmail & "', userHomeAddress = '" & userHomeAddress & "', userHomePhone = '" & userHomePhone & "', userHomeEmail = '" & userHomeEmail & "', WHERE userID = '" & userID
Else
levelID = stripQuotes(Request.Form("levelID"))
userDept = stripQuotes(Request.Form("userDept"))
strSQL = "UPDATE tblUsers SET userFirstName = '" & userFirstName & "', userLastName = '" & userLastName & "', userJobTitle = '" & userJobTitle & "', userInternalPhone = '" & userInternalPhone & "', userInternalEmail = '" & userInternalEmail & "', userDept = '" & userDept & "', WHERE userID = '" & userID
End If
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open MM_dsnIKH_STRING
response.write strSQL
'update the record
adoCon.Execute(strSQL)
if isUser = false Then
'delete the levels from the database
strSQL = "DELETE FROM tblUser_levels WHERE userID = " & userID
adoCon.execute(strSQL)
'insert the levels
'split the values sent for levelID into an array using the VBScript Split function
alevelID = Split(levelID, ",")
'loop through that array inserting the levelID and userID
For Each i In alevelID
strSQL = "INSERT INTO tblUser_levels (userID, levelID) VALUES (" & userID & ", " & i & ")"
adoCon.execute(strSQL)
Next
end if
adoCon.Close
Set adoCon = Nothing
Response.Redirect "/IntranetDesignProject/list.asp"
%>
I keep getting this message...
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
/IntranetDesignProject/admin/edituser_script.asp, line 45
line 45 is
adoCon.Execute(strSQL)
all of the script comes directly out of Dreamweaver MX 2004 Design Projects.
My instructor can not find the problem...
In fact he has the same problem on his page
I am very new to this, so it is difficult for me to find problems and fix them...
could someone please, please, please help me with this?
[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
/IntranetDesignProject/admin/edituser_script.asp, line 45
[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
/IntranetDesignProject/admin/edituser_script.asp, line 45
UPDATE tblUsers SET userFirstName = 'Manager', userLastName = 'Manager', userJobTitle = 'Manager', userInternalPhone = '1616', userInternalEmail = 'manager', userDept = '', WHERE userID = 5
before the WHERE delete the "," so it is
UPDATE tblUsers SET userFirstName = 'Manager', userLastName = 'Manager', userJobTitle = 'Manager', userInternalPhone = '1616', userInternalEmail = 'manager', userDept = '' WHERE userID = 5
so the problem is somewhere in this statement
strSQL = "UPDATE tblUsers SET userFirstName = '" & userFirstName & "', userLastName = '" & userLastName & "', userJobTitle = '" & userJobTitle & "', userInternalPhone = '" & userInternalPhone & "', userInternalEmail = '" & userInternalEmail & "', userDept = '" & userDept & "' WHERE userID = " & userID