Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: Cannot update. Database or object is read-only 1

Status
Not open for further replies.

snowxf

Technical User
Jan 5, 2005
20
0
0
US
I'm trying to add a record to a table, using VBScript. I haven't had any problems viewing records, but now I'm adding in this capability, and I'm having issues with opening a read/write recordset.

The error I'm getting is this:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object is read-only.

It occurs on the record.Update line in the following code:
Code:
<!-- #INCLUDE FILE="adovbs.inc" -->
<%

'...

Sub displayRecord(mode, table, id)
'{'
	Dim counter
	counter = 1
	Dim database	'as connection'
	Dim records		'as recordset'
	Dim strSQL		'as SQL statement'
	Dim nbrFields
	Dim fieldName

	Set database = Server.CreateObject("ADODB.Connection")
	'database.Mode = adModeReadWrite'
	database.Open "testdb"

	If mode = "addnew" Then
		Call addRecord(database, table, id)

'...skip to addRecord ...

Sub addRecord(dbConnection, table, id)
'{'
	Dim record	'as recordset'

	Set record = Server.CreateObject("ADODB.Recordset")
	record.Open table, dbConnection, adOpenDynamic, adLockOptimistic
	record.AddNew
	record("Name") = "test"
	id = record("ID")
	record.Update
	record.Close
	Set record = Nothing
'}'
End Sub

You can also see where I tried, unsuccessfully, to change database.Mode after I was reading around on Microsoft "help" pages and thought that might have something to do with it.
Thanks for any ideas you can provide!
 
what is "testdb" ???

Perhaps you are using a microsoft access database and the IUSR_MachineName account does not have write access to the .mdb file.

This can drive you crazy if you explicitly give the account access but then you run the compact & repair wizard and access is lost because the file is actually destroyed and recreated.
 
Oh, sorry. "testdb" is the System DSN through ODBC that points to the Microsoft Access Database. The database is on my local machine and I can open/write to it directly without any problem, so I didn't think that would be an issue. But how can I check IUSR_MachineName to see if it has access?
 
Oh well IIS uses a special local Account with that name to do its operations. The purpose of this is to prevent web users from having much power on your machine besides what you explicitly let them do.

On of the downsides is that you have to make sure that this account has security privilages for anything you want to read.

Another way you can do it is just to turn off anonymous access in your IIS and force web users to authenticate against your machine.
 
What I'm trying to say is that although YOUR account has priviliages to the file that doesn't mean that you will be able to see it because, by default, the ASP operates in the context of this other local account.
 
Okay, I'm pretty sure I'm following. :) I went to IIS and in Web Sites Properties, Directory Security tab, looked up "anonymous access and authentication control." Currently it's set with Anonymous Access checked,
No user name/password required to access this resource.
Account used for anonymous access:
User name: IUSR_COMPUTER1

The password is grayed out and Allow IIS to control password is checked. Computer1 is the name of this computer I'm using, and no one else needs to access the database right now while I'm setting it up. But you're saying I should un-check Anonymous Access, and that should let my computer have access to it then? (Should I mention I'm a bit confused?? ;)
 
Keep Anonymous access checked and just grant the IUSR accont read/write permissions on the folder that contains your database.


Tony
________________________________________________________________________________
 
Yea - that did it! I went to the folder and looked at Security under Properties, and sure enough, the "Users" only had Read permissions. Now if I could just get it to return the primary key value... Hey, thanks you two for helping me figure out all this IUSR stuff!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top