longmatch
Programmer
- Nov 1, 2001
- 406
I just got this code from chapter 15 of the booK titled "Beginning Active Server Pages 3.0". When I ran this piece of codes, I got this message:
Error Type:
Microsoft JET Database Engine (0x80040E09)
Cannot update. Database or object is read-only.
/ch15/AddUser.asp, line 13
I do not know why. I did change the cursor type from adOpenForwardOnly to adOpenDynamic. Unfortunately it did not work. I am hoping you can give me the answer and fix it.
Thank you in advance
Haijun
<%
Dim rsUsers
Set rsUsers = Server.CreateObject("ADODB.Recordset"
rsUsers.Open "Person", objConn, adOpenForwardOnly, adLockOptimistic, adCmdTable
If Session("PersonID"
<> "" Then ' currently logged-on user
rsUsers.Filter = "PersonID = '" & Session("PersonID"
& "'"
Else ' New session
rsUsers.Filter = "EMailAddress = '" & Request.Form("email"
& "'" & _
"AND Password = '" & Request.Form("password"
& "'"
If rsUsers.EOF Then ' User not found
rsUsers.AddNew ' ...so add a new record
' Else
' Email address and password matched with DB records -
' In this case we'll allow this to update user's personal details
End If
End If
' write personal details to record
rsUsers("EMailAddress"
= Request.Form("email"
rsUsers("Password"
= Request.Form("password"
rsUsers("FamilyName"
= Request.Form("FamilyName"
rsUsers("GivenName"
= Request.Form("GivenName"
rsUsers("StreetAddress1"
= Request.Form("Address1"
rsUsers("StreetAddress2"
= Request.Form("Address2"
rsUsers("City"
= Request.Form("City"
rsUsers("State"
= Request.Form("State"
rsUsers("PostalCode"
= Request.Form("PostalCode"
rsUsers("Country"
= Request.Form("Country"
rsUsers("Active"
= True
rsUsers("LastLogin"
= Now
rsUsers.Update ' update the database
Dim strName, strValue ' create session variables
For each strField in rsUsers.Fields
strName = strField.Name
strValue = strField.value
Session(strName) = strValue
Next
Session("blnValidUser"
= True ' declare that current user is validated
Response.Redirect "MenuForRegisteredUsers.asp"
%>
Error Type:
Microsoft JET Database Engine (0x80040E09)
Cannot update. Database or object is read-only.
/ch15/AddUser.asp, line 13
I do not know why. I did change the cursor type from adOpenForwardOnly to adOpenDynamic. Unfortunately it did not work. I am hoping you can give me the answer and fix it.
Thank you in advance
Haijun
<%
Dim rsUsers
Set rsUsers = Server.CreateObject("ADODB.Recordset"

rsUsers.Open "Person", objConn, adOpenForwardOnly, adLockOptimistic, adCmdTable
If Session("PersonID"

rsUsers.Filter = "PersonID = '" & Session("PersonID"

Else ' New session
rsUsers.Filter = "EMailAddress = '" & Request.Form("email"

"AND Password = '" & Request.Form("password"

If rsUsers.EOF Then ' User not found
rsUsers.AddNew ' ...so add a new record
' Else
' Email address and password matched with DB records -
' In this case we'll allow this to update user's personal details
End If
End If
' write personal details to record
rsUsers("EMailAddress"


rsUsers("Password"


rsUsers("FamilyName"


rsUsers("GivenName"


rsUsers("StreetAddress1"


rsUsers("StreetAddress2"


rsUsers("City"


rsUsers("State"


rsUsers("PostalCode"


rsUsers("Country"


rsUsers("Active"

rsUsers("LastLogin"

rsUsers.Update ' update the database
Dim strName, strValue ' create session variables
For each strField in rsUsers.Fields
strName = strField.Name
strValue = strField.value
Session(strName) = strValue
Next
Session("blnValidUser"

Response.Redirect "MenuForRegisteredUsers.asp"
%>