Subject: UPDATING problem
Posted By: CW Post Date: 9/12/2003 3:51:29 AM
This is the updating asp script.

<% 'Dimension variables
Dim adoCon            'Holds the Database Connection Object
Dim rsUpdateEntry   'Holds the recordset for the record to be updated
Dim strSQL             'Holds the SQL query to query the database
Dim getRecordID     'Holds the record number to be updated
'Read in the record number to be updated
getRecordID= CLng(Request.Form("ID_no"))
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using
'DSN connection
adoCon.Open "DSN=Guest"
'Create an ADO recordset object
Set rsUpdate = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblName.* FROM tblStudents WHERE ID_no=" & getRecordID
'Set the cursor type we are using so we can navigate through
'the recordset
rsUpdate.CursorType = 2
'Set the lock type so that the record is locked by ADO when it
'is updated
rsUpdate.LockType = 3
'Open the recordset with the SQL query
rsUpdate.Open strSQL, adoCon
'Update the record in the recordset
rsUpdate.Fields("FName") = Request.Form("fname")
rsUpdate.Fields("LName") = Request.Form("lname")
'Write the updated recordset to the database
rsUpdate.Update
'Reset server objects
rsUpdate.Close
rsUpdate= Nothing
Set adoCon = Nothing
%>

When i execute this scripts from the update-form, i will get an error wich says:
 Database or Object is Read-Only.

I have checked the Guest database, and it is not read-only.
Permission is OK. Even the option button in the ODBC microsoft access setup is not Read-only.

Could any one help !!!!


Thanks in advance




Reply By: pgtips Reply Date: 9/12/2003 5:08:58 AM
This line
strSQL = "SELECT tblName.* FROM tblStudents WHERE ID_no=" & getRecordID
looks a bit strange, shouldn't it be
strSQL = "SELECT tblStudents.* FROM tblStudents WHERE ID_no=" & getRecordID
?

I'm curious though, this seems like a long-winded way to do an update.  What's wrong with executing a SQL UPDATE statement instead:

<% 'Dimension variables
Dim adoCon            'Holds the Database Connection Object 
Dim strSQL             'Holds the SQL query to query the database 
Dim getRecordID     'Holds the record number to be updated

'Read in the record number to be updated
getRecordID= CLng(Request.Form("ID_no"))

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using 
'DSN connection
adoCon.Open "DSN=Guest"

'Initialise the strSQL variable with an SQL statement to update the database
strSQL = "UPDATE tblStudents "
strSQL = strSQL & "SET FName = '" & Replace(Request.Form("fname"), "'", "''") & "',"
strSQL = strSQL & "LName = '" & Replace(Request.Form("lname"), "'", "''") & "'"
strSQL = strSQL & " WHERE ID_no=" & getRecordID

'Update the record in the recordset
Const adExecuteNoRecords = 128
adoCon.Execute strSQL, , adExecuteNoRecords

'Reset server objects
adoCon.Close
Set adoCon = Nothing
%> 


hth
Phil
Reply By: lcsgeek Reply Date: 9/12/2003 7:53:48 AM
I don’t believe your problem is code as much as it is Operating System/File system security.  I’ve been fighting this same problem with Windows XP and just learned that I needed to give the IUSR_machinename user, NTFS permissions to the folder where my data resides on disk.  Which I suspected but couldn’t find the security tab when doing a properties on the folder in question.  I just learned that you need to go to Tools | Folder Options | View tab; all the way at the bottom is a ‘Use simple file sharing option’.  Uncheck this and you get your Security tab while doing a properties on a folder.  Now you can grant IUSR_machinename user NTFS (minimum: Read & Execute, List Folder Contents, Read and Write) permission to the location of the database files and life should be good.
Reply By: DaveGerard Reply Date: 9/23/2003 4:25:35 PM
Tried this?

rsUpdate.Open strSQL, adoCon, 3, 3


Go to topic 4469

Return to index page 1040
Return to index page 1039
Return to index page 1038
Return to index page 1037
Return to index page 1036
Return to index page 1035
Return to index page 1034
Return to index page 1033
Return to index page 1032
Return to index page 1031