Click to See Complete Forum and Search --> : Cannot update Error


Squall Leonhart
12-22-2003, 08:43 PM
Hi, guys.

I want to add the items to the access database.
I run the site on IIS in XP pro.
I have written the following code. Please have a look.



update.asp


code:--------------------------------------------------------------------------------
<%
Dim adoCon 'Holds the Database Connection Object
Dim rsAddComments 'Holds the recordset for the new record to be added to the database
Dim strSQL 'Holds the SQL query for the database
Set adoCon = Server.CreateObject("ADODB.Connection")
Set rsAddComments = Server.CreateObject("ADODB.Recordset")
adoCon = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("game.mdb")

Select Case Request.Querystring("state")

Case "add"
strSQL = "SELECT * FROM tblGame;"
rsAddComments.CursorType = 2
rsAddComments.LockType = 3
rsAddComments.Open strSQL, adoCon
rsAddComments.AddNew
rsAddComments.Fields("title") = Request.Form("title")
rsAddComments.Fields("genre") = Request.Form("genre")
rsAddComments.Fields("Content") = Request.Form("content")
rsAddComments.Update
rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing
Response.Redirect "post.asp"
End select
%>
--------------------------------------------------------------------------------


When the this page loads, error message

'Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object is read-only.'

appears. Do you guys know what would cause this kind of error?
Thanks.

PeOfEo
12-22-2003, 09:15 PM
I had to deal with this myself not a month ago :D. Sounds like you do not have the permissions setup for that data base. XP, unlike its other nt cousins has something called simple share enabled by default, this relates to shareing between user accounts. Make sure simple share is off on xp, then right click the data base and set the access to scripts read write etc. If simple share is on you need to go into the folder the data base is in, go to the tools tab on the top menu, then go to folder options, then to the view tab then scroll down to the last option, simple share and uncheck it. The set the security settings for the data base. The problem is a system account that iis is running to run asp or aspnet needs to be able to alter the data base but because it is another user account it is read only by default and you have to get rid of that.

PeOfEo
12-25-2003, 01:49 AM
You get it working?