Can someone help me please. I am able to query the database, but when I attempt to do an update on the recordset I get the "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another." message on the following line:
objUserRS.Open strUserSQL, objUserConn, adOpenKeyset, adLockPessimistic, adCmdText
When I remove the parameters for the recordset after the connection object I get an error stating the recordset is not updateable - see line in yellow.
Here is the code:
response.Buffer = true
' BEGIN USER CONSTANTS
Dim CONN_STRING
Dim CONN_USER
Dim CONN_PASS
dim strUserSQL
dim objUserConn
dim objUserRS
dim attempts
dim fname
dim lname
response.Cookies("Login")("ses") = "True"
un = request.Form("un")
' Create and open our connection
Set objUserConn = Server.CreateObject("ADODB.Connection")
objUserConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("SummitPump.mdb")
strUserSQL = "SELECT * FROM Users WHERE User='" & request.Form("un") & "'"
Set objUserRS = Server.CreateObject("ADODB.Recordset")
objUserRS.Open strUserSQL, objUserConn, adOpenKeyset, adLockPessimistic, adCmdText
attempts = objUserRS("attempts")
fname = objUserRS("fname")
'determine if first time logging in...if so, force them to change password and PIN
if objUserRS("firsttime") = true then
if objUserRS("password") = "password" then
response.Redirect ("newlogin.asp?un=" & un)
else
response.Redirect ("error.asp?av=1")
end if
else
response.Cookies("Login")("un") = request.Form("un")
response.Cookies("Login").expires = date + 365
dim objUserCmd
if request.Form("save") = "on" then
response.Cookies("Login")("pw") = request.Form("pw")
response.Cookies("Login")("saved") = "Yes"
response.Cookies("Login").expires = date + 365
else
response.Cookies("Login")("pw") = ""
response.Cookies("Login")("saved") = "No"
end if
'determine if username active - username is inactive after 3 failed login attempts
if objUserRS("active") = 1 then
if objUserRS("password") = request.Form("pw") then
strUserSQL = "UPDATE Users Set Attempts = 0 WHERE User = '" & un & "'"
'create the command object
'set objUserCmd = server.CreateObject("ADODB.Command")
objUserRS("Attempts") = request.Form("pw")
objUserRS.update objUserRS.close
response.Write (objUserRS("FName"))
'response.Redirect ("User.asp?nm=" & name & "")
else
'determine if this was third attempt and if so, make username in active
if objUserRS("attempts") = 2 then
strUserSQL = "UPDATE Users Set Attempts = " & objUserRS("attempts") + 1 & ", Active = 0 WHERE UserID = '" & un & "'"
'create the command object
set objUserCmd = server.CreateObject("ADODB.Command")
'set the command object properties
set objUserCmd.ActiveConnection = objUserConn
objUserCmd.CommandText = strUserSQL
'objUserCmd.CommandType = adCmdText
'execute the command
objUserCmd.Execute
response.Redirect ("error.asp?av=0")
else
attempts = attempts + 1
strUserSQL = "UPDATE Users Set Attempts = " & objUserRS("attempts") + 1 & " WHERE UserID = '" & un & "'"
'create the command object
set objUserCmd = server.CreateObject("ADODB.Command")
'set the command object properties
set objUserCmd.ActiveConnection = objUserConn
objUserCmd.CommandText = strUserSQL
'objUserCmd.CommandType = adCmdText
'execute the command
objUserCmd.Execute
'response.Redirect ("error.asp?av=1&no= & attempts & "")")
response.Redirect ("error.asp?av=1&no=" & attempts)
end if
end if
' else
' 'username is not active
' response.Write "Your account is not active. Please contact James to reset your account."
End if
end if
' Close DB objects and free variables
objUserRS.Close
Set objUserRS = Nothing
objUserConn.Close
set objUserConn = Nothing
set objUserCmd = nothing
objUserRS.Open strUserSQL, objUserConn, adOpenKeyset, adLockPessimistic, adCmdText
When I remove the parameters for the recordset after the connection object I get an error stating the recordset is not updateable - see line in yellow.
Here is the code:
response.Buffer = true
' BEGIN USER CONSTANTS
Dim CONN_STRING
Dim CONN_USER
Dim CONN_PASS
dim strUserSQL
dim objUserConn
dim objUserRS
dim attempts
dim fname
dim lname
response.Cookies("Login")("ses") = "True"
un = request.Form("un")
' Create and open our connection
Set objUserConn = Server.CreateObject("ADODB.Connection")
objUserConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("SummitPump.mdb")
strUserSQL = "SELECT * FROM Users WHERE User='" & request.Form("un") & "'"
Set objUserRS = Server.CreateObject("ADODB.Recordset")
objUserRS.Open strUserSQL, objUserConn, adOpenKeyset, adLockPessimistic, adCmdText
attempts = objUserRS("attempts")
fname = objUserRS("fname")
'determine if first time logging in...if so, force them to change password and PIN
if objUserRS("firsttime") = true then
if objUserRS("password") = "password" then
response.Redirect ("newlogin.asp?un=" & un)
else
response.Redirect ("error.asp?av=1")
end if
else
response.Cookies("Login")("un") = request.Form("un")
response.Cookies("Login").expires = date + 365
dim objUserCmd
if request.Form("save") = "on" then
response.Cookies("Login")("pw") = request.Form("pw")
response.Cookies("Login")("saved") = "Yes"
response.Cookies("Login").expires = date + 365
else
response.Cookies("Login")("pw") = ""
response.Cookies("Login")("saved") = "No"
end if
'determine if username active - username is inactive after 3 failed login attempts
if objUserRS("active") = 1 then
if objUserRS("password") = request.Form("pw") then
strUserSQL = "UPDATE Users Set Attempts = 0 WHERE User = '" & un & "'"
'create the command object
'set objUserCmd = server.CreateObject("ADODB.Command")
objUserRS("Attempts") = request.Form("pw")
objUserRS.update objUserRS.close
response.Write (objUserRS("FName"))
'response.Redirect ("User.asp?nm=" & name & "")
else
'determine if this was third attempt and if so, make username in active
if objUserRS("attempts") = 2 then
strUserSQL = "UPDATE Users Set Attempts = " & objUserRS("attempts") + 1 & ", Active = 0 WHERE UserID = '" & un & "'"
'create the command object
set objUserCmd = server.CreateObject("ADODB.Command")
'set the command object properties
set objUserCmd.ActiveConnection = objUserConn
objUserCmd.CommandText = strUserSQL
'objUserCmd.CommandType = adCmdText
'execute the command
objUserCmd.Execute
response.Redirect ("error.asp?av=0")
else
attempts = attempts + 1
strUserSQL = "UPDATE Users Set Attempts = " & objUserRS("attempts") + 1 & " WHERE UserID = '" & un & "'"
'create the command object
set objUserCmd = server.CreateObject("ADODB.Command")
'set the command object properties
set objUserCmd.ActiveConnection = objUserConn
objUserCmd.CommandText = strUserSQL
'objUserCmd.CommandType = adCmdText
'execute the command
objUserCmd.Execute
'response.Redirect ("error.asp?av=1&no= & attempts & "")")
response.Redirect ("error.asp?av=1&no=" & attempts)
end if
end if
' else
' 'username is not active
' response.Write "Your account is not active. Please contact James to reset your account."
End if
end if
' Close DB objects and free variables
objUserRS.Close
Set objUserRS = Nothing
objUserConn.Close
set objUserConn = Nothing
set objUserCmd = nothing
Comment